Skip to main content

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

Light and Dark Themes

If you only need light 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

The system 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:
themes
Array<string>
The list of available themes.Default:
adaptiveThemes
boolean
Whether themes automatically adapt to the device’s color scheme.Default:
initialTheme
string
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 the setTheme 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.
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 the useUniwind hook to access theme information and automatically re-render when the theme changes:

API Reference

Uniwind Global Object

setTheme
(themeName: string) => void
Changes the active theme at runtime.Parameters:
  • themeName: The name of the theme to activate ('light', 'dark', 'system', or a custom theme name)
currentTheme
string
The name of the currently active theme.Returns: 'light', 'dark', 'system', or a custom theme name
hasAdaptiveThemes
boolean
Indicates whether adaptive themes are currently enabled.Returns: true if adaptive themes are enabled, false otherwise
updateCSSVariables
(theme: string, variables: Record<string, string | number>) => void
Dynamically updates CSS variables at runtime for a specific theme.Parameters:
  • theme: The name of the theme to update ('light', 'dark', or a custom theme name)
  • variables: An object mapping CSS variable names (with -- prefix) to their new values
For detailed usage examples and platform-specific behavior, see the updateCSSVariables documentation.

Using Theme Variants in ClassNames

Apply different styles based on the active theme using the dark: 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.

Custom Themes

Learn how to create custom themes beyond light and dark

useUniwind Hook

Access theme information in your React components

Global CSS

Define global CSS variables for your themes

Update CSS Variables

Dynamically update CSS variables at runtime

Style Based on Themes

Advanced theme-based styling techniques