Overview
Uniwind provides a powerful theming system that allows you to create beautiful, consistent user interfaces that adapt to user preferences. By default, Uniwind includes three pre-configured themes:light, dark, and system.
Default Themes
Uniwind pre-registers three themes out of the box, so you can start using them immediately without any configuration.Available Themes
| Theme | Description |
|---|---|
light | Light theme |
dark | Dark theme |
system | Automatically follows the device’s system color scheme preferences |
Light and Dark Themes
If you only needlight and dark themes, you’re all set! Uniwind automatically registers these themes for you, and you can start using theme-based class variants immediately:
System Theme
Thesystem theme is a special theme that automatically syncs with your device’s color scheme. When enabled, your app will automatically switch between light and dark themes based on the user’s device settings.
Default Configuration
Here are the default values that Uniwind uses for theming:The list of available themes.Default:
Whether themes automatically adapt to the device’s color scheme.Default:
The theme that’s applied when the app first launches.Default:Automatically determined based on your device’s current color scheme.
Changing Themes
You can programmatically change the active theme at runtime using thesetTheme function.
Switch to a Specific Theme
When you set the theme to
light or dark, Uniwind automatically calls React Native’s Appearance.setColorScheme. This ensures native components like Alert, Modal, and system dialogs match your app’s theme.Enable System Theme
To enable automatic theme switching based on the device’s color scheme:Creating a Theme Switcher
Here’s a complete example of a theme switcher component:Accessing Theme Information
Uniwind exposes a global object that provides information about the current theme state.Runtime Theme Information
You can access theme information programmatically:Using the useUniwind Hook
For React components, use theuseUniwind hook to access theme information and automatically re-render when the theme changes:
API Reference
Uniwind Global Object
Changes the active theme at runtime.Parameters:
themeName: The name of the theme to activate ('light','dark','system', or a custom theme name)
The name of the currently active theme.Returns:
'light', 'dark', 'system', or a custom theme nameIndicates whether adaptive themes are currently enabled.Returns:
true if adaptive themes are enabled, false otherwiseUsing Theme Variants in ClassNames
Apply different styles based on the active theme using thedark: variant: