Web styles
Unistyles web is fully independent from React Native Web, thanks to our custom web parser that generates CSS directly from your StyleSheet
definitions.
How it works?
The web parser generates unique classNames
based on your configuration and assigns them to the corresponding DOM elements, ensuring no redundant styles are applied.
Additionally, we generate media queries based on the provided breakpoints
, so the app doesn’t need to recalculate them on every resize event.
This results in the following CSS output:
Updating styles
When you change the theme of your app, Unistyles will update your CSS without triggering any re-renders. This also applies to dynamic functions and variants.
For example, if you define styles like this:
The generated CSS might look like:
When you switch the theme:
The CSS will automatically update to:
Limitations
Since we are using a custom parser, we can’t return your styles directly as React Native Web would do, because it would parse them differently.
Therefore, when using StyleSheet.create
on the web, you won’t be able to access the styles directly.
Web Only Features
Unistyles also includes web-specific features. You can learn more about them here.