Configuration
To unlock more features and tailor Unistyles to your needs, you can configure it. The Unistyles configuration is divided into three parts:
- Themes
- Breakpoints
- Settings
Themes (Optional)
Themes
is a JavaScript object where the keys represent unique theme names, and the values are the corresponding theme definitions. For more details, refer to the theming guide.
Breakpoints (Optional)
Breakpoints
is a JavaScript object where the keys are unique breakpoint names and the values are the corresponding breakpoint values (numbers). Be sure to register at least one breakpoint with a value of 0, as it’s required to simulate the cascading behavior of CSS media queries.
Settings (Optional)
The Settings
object has been simplified, and in the most recent version, it supports only two properties:
adaptiveThemes
– a boolean that enables or disables adaptive themes learn moreinitialTheme
– a string or a synchronous function that sets the initial theme.
TypeScript Types (Optional)
If your repository is using TypeScript, it is highly recommended to override the library types for optimal autocomplete and type safety regarding your themes and breakpoints:
Set configuration
The final step in the configuration is to set all the options by calling the StyleSheet.configure
function:
That’s it! You can now use all the features of Unistyles in your project!