useThemeUI hook provides access to the Theme UI context, including the current theme and color mode functions.
Import
Signature
Return Value
ThemeUIContextValue
The Theme UI context object
Theme
The current theme object with all merged values
string
The current color mode (e.g., ‘default’, ‘dark’). Available when using ThemeUIProvider.
(mode: string) => void
Function to change the current color mode. Available when using ThemeUIProvider.
string
Internal version string for Emotion compatibility checking
Usage
Accessing Theme Values
Accessing Color Mode
Reading Nested Theme Values
Using with TypeScript
The hook is fully typed and will provide autocomplete for your theme:Example: Theme-Aware Component
Example: Using in Tests
Notes
- This hook must be used within a
ThemeUIProviderorThemeProvidercomponent - The
colorModeandsetColorModeproperties are only available when usingThemeUIProvider(not the coreThemeProvider) - The returned
themeobject is the fully merged theme, including any nested provider themes
Related
- ThemeUIProvider - Root theme provider component
- Theme Specification - Theme object structure
- Color Modes - Working with color modes
