@theme-ui/theme-provider package provides the full-featured ThemeUIProvider component that combines the core theme provider with color mode support and root styles.
Installation
This package is included in the main
theme-ui package. You typically don’t need to install it separately. The main theme-ui package re-exports ThemeUIProvider.When to Use
This package is primarily for internal use. You would only install it directly if you’re:- Building a custom Theme UI configuration
- Using specific Theme UI packages without the umbrella package
- Need the provider without other Theme UI utilities
theme-ui package which includes this provider:
Exports
Components
ThemeUIProvider
The main provider component that sets up Theme UI for your application.
theme:Theme- Your theme objectchildren:React.ReactNode- Child components
- Provides theme context to all child components
- Enables color mode functionality
- Applies root styles to
<html>and<body> - Sets up CSS custom properties
- Configures border-box box-sizing by default
ThemeProvider (deprecated)
A deprecated alias for ThemeUIProvider.
What It Does
TheThemeUIProvider combines several features:
1. Core Theme Provider
Provides theme context from@theme-ui/core:
2. Color Mode Support
Adds color mode functionality from@theme-ui/color-modes:
3. Root Styles
Applies global root styles to your application:Usage
Basic Setup
With Root Styles
With Color Modes
Nested Providers
You can nest providers to override theme values in specific sections:Configuration
Configure provider behavior in your theme:Configuration Options
useCustomProperties
Type: booleanDefault:
true
Generate CSS custom properties for theme values:
useBorderBox
Type: booleanDefault:
true
Apply box-sizing: border-box to all elements:
useRootStyles
Type: booleanDefault:
true
Apply theme.styles.root to the <html> element:
Color Mode Options
See @theme-ui/color-modes for color mode configuration.Implementation Details
Root Styles Logic
Root styles are only applied:- On the top-level provider (not nested providers)
- When
useRootStylesis notfalse - When
theme.styles.rootexists (for root variant)
Multiple Versions Warning
If multiple versions of@emotion/react are detected, a warning is logged in development mode.
Dependencies
The package depends on:TypeScript Types
Notes
- This is primarily an internal package
- Most users should import from
theme-uiinstead - Combines core provider, color modes, and root styles
- Requires React 18 or higher
- Requires
@emotion/reactas a peer dependency - No side effects - safe for tree-shaking
Related
- @theme-ui/core - Core theme provider without extras
- @theme-ui/color-modes - Color mode utilities
- theme-ui - Main package documentation
- Getting Started - Setup guide
