useThemeUI hook provides access to the Theme UI context, including the current theme and color mode functions.
Import
Signature
Return Value
The Theme UI context object
The current theme object with all merged values
The current color mode (e.g., ‘default’, ‘dark’). Available when using ThemeUIProvider.
Function to change the current color mode. Available when using ThemeUIProvider.
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
