Skip to main content

Installation

Get started with Theme UI by installing the package and its peer dependencies.

Prerequisites

Theme UI requires the following in your project:
  • Node.js: Version 18.0.0 or higher
  • React: Version 18 or higher

Install Dependencies

Theme UI has a peer dependency on @emotion/react, which must be installed alongside the main package.
The theme-ui package includes all features: the sx prop, color modes, and UI components. If you don’t need color modes or components, you can install the lighter @theme-ui/core package instead.

Lightweight Alternative

For a minimal installation without color modes or components:

Setup

After installation, set up Theme UI in your application by creating a theme and wrapping your app with the ThemeUIProvider.

Step 1: Create a Theme

Create a theme file that defines your design tokens. The theme object follows the System UI Theme Specification. Create a file called theme.js (or theme.ts for TypeScript):
theme.js

Step 2: Add the Provider

Wrap your application with the ThemeUIProvider component and pass in your theme object.
App.jsx
The ThemeUIProvider should be placed at the root of your application to make the theme available to all components.

Step 3: Enable the sx Prop

To use the sx prop in your components, add the JSX pragma comment at the top of each file:
The /** @jsxImportSource theme-ui */ pragma tells your build tool to use Theme UI’s custom JSX function, which enables the sx prop.
The pragma is required for the sx prop to work. Without it, the sx prop will be ignored. You need to add it to every file where you want to use sx.

TypeScript Support

Theme UI includes full TypeScript definitions. No additional setup is required for TypeScript support.

Verify Installation

To verify that Theme UI is installed correctly, create a simple component using the sx prop:
test.jsx
If the component renders with styles from your theme, you’re ready to start building!

Next Steps

Quickstart

Learn how to create your first themed component