ThemeUIProvider component is the primary way to add a theme to your application. It wraps the core ThemeProvider and adds color mode support and global root styles.
Import
Signature
Usage
Basic Usage
Functional Theme
You can pass a function to merge with an outer theme:With Root Styles
TheThemeUIProvider automatically applies root styles from theme.styles.root:
Features
Automatic Root Styles
At the top level,ThemeUIProvider injects global styles that:
- Set
box-sizing: border-boxon all elements (unlessconfig.useBorderBoxisfalse) - Apply
styles.rootvariant to thehtmlelement - Reset body margin to
0
Color Mode Support
Wraps children withColorModeProvider for automatic color mode support. See the Color Modes documentation for details.
Nested Providers
You can nest multipleThemeUIProvider components to merge themes. Inner themes are deeply merged with outer themes:
Configuration
Control provider behavior throughtheme.config:
Whether to apply root styles from
theme.styles.rootWhether to set
box-sizing: border-box on all elementsWhether to use CSS custom properties for color values
Related
- useThemeUI - Access theme context in components
- ThemeProvider - Core provider without color modes
- Color Modes - Working with color modes
