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.
Using the
system
theme provides the best user experience, as it respects the user’s device-wide preferences.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
Switching from
system
to light
or dark
disables adaptive themes. The app will stay on the selected theme even if the device color scheme changes.Enable System Theme
To enable automatic theme switching based on the device’s color scheme:Setting the theme to
system
re-enables adaptive themes, allowing your app to automatically follow device color scheme changes.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:
Best Practices
Use semantic color names: Instead of hardcoding colors, define theme-aware color tokens in your Tailwind config for better consistency.
Test both themes: Always test your UI in both light and dark themes to ensure proper contrast and readability.
Avoid theme-specific logic in components: Let the styling system handle theme switching. Keep your component logic theme-agnostic.