Skip to main content
The 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

ThemeProviderProps
Props for the ThemeUIProvider component
Theme | ((outerTheme: Theme) => Theme)
required
Theme object or function that receives the outer theme and returns a new theme
React.ReactNode
Child components that will have access to the theme context

Usage

Basic Usage

Functional Theme

You can pass a function to merge with an outer theme:

With Root Styles

The ThemeUIProvider 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-box on all elements (unless config.useBorderBox is false)
  • Apply styles.root variant to the html element
  • Reset body margin to 0

Color Mode Support

Wraps children with ColorModeProvider for automatic color mode support. See the Color Modes documentation for details.

Nested Providers

You can nest multiple ThemeUIProvider components to merge themes. Inner themes are deeply merged with outer themes:

Configuration

Control provider behavior through theme.config:
boolean
default:"true"
Whether to apply root styles from theme.styles.root
boolean
default:"true"
Whether to set box-sizing: border-box on all elements
boolean
default:"true"
Whether to use CSS custom properties for color values