Skip to main content
The @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
For most projects, use the theme-ui package which includes this provider:

Exports

Components

ThemeUIProvider

The main provider component that sets up Theme UI for your application.
Props:
  • theme: Theme - Your theme object
  • children: React.ReactNode - Child components
Features:
  • 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.
ThemeProvider is deprecated to avoid confusion with Emotion’s ThemeProvider. Use ThemeUIProvider instead. The ThemeProvider export will be removed in a future version.

What It Does

The ThemeUIProvider 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: boolean
Default: true
Generate CSS custom properties for theme values:

useBorderBox

Type: boolean
Default: true
Apply box-sizing: border-box to all elements:

useRootStyles

Type: boolean
Default: 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 useRootStyles is not false
  • When theme.styles.root exists (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-ui instead
  • Combines core provider, color modes, and root styles
  • Requires React 18 or higher
  • Requires @emotion/react as a peer dependency
  • No side effects - safe for tree-shaking