Configuration
In order to use more features and tailor Unistyles to your needs, you need to configure it. Unistyles config has been divided into three parts:
- Themes
- Breakpoints
- Settings
Themes (optional)
Themes
is a JavaScript object where keys are unique theme names and values are actual themes. To learn more about themes, check out theming guide.
Breakpoints (optional)
Breakpoints
is also a JavaScript object where keys are unique breakpoint names and values are actual breakpoints values (numbers). You should make sure that you register at least one breakpoint with value 0 as it’s necessary to simulate CSS media queries cascading.
Settings (optional)
Settings
object was simplified and in the most recent version it supports only two properties:
adaptiveThemes
- boolean, enables or disables adaptive themes learn moreinitialTheme
- string, or synchronous function that sets initial theme
TypeScript (optional)
If your repository is using TypeScript is highly recommended to override library types to get perfect autocomplete and type safety about your themes and breakpoints:
Set configuration
The final piece of configuration is to set all the configs by calling StyleSheet.configure
function:
That’s it! Now you can use Unistyles in your project!