Skip to main content

The Design Graph Framework

Build themeable user interfaces with constraint-based design principles. Theme UI provides a powerful styling system for creating design systems, component libraries, and custom themes.

Quick Start

Get up and running with Theme UI in minutes

1

Install Theme UI

Install the package and its peer dependencies using your preferred package manager.
npm install theme-ui @emotion/react
2

Create a theme

Define your theme object with colors, typography, spacing, and other design tokens.
theme.js
export default {
  fonts: {
    body: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
    heading: '"Avenir Next", sans-serif',
    monospace: 'Menlo, monospace',
  },
  colors: {
    text: '#000',
    background: '#fff',
    primary: '#33e',
    secondary: '#119',
    muted: '#f6f6f6',
  },
  fontSizes: [12, 14, 16, 20, 24, 32, 48, 64, 96],
  space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
}
3

Add the ThemeUIProvider

Wrap your application with the ThemeUIProvider component to make your theme available throughout your app.
App.jsx
import { ThemeUIProvider } from 'theme-ui'
import theme from './theme'

export default function App() {
  return (
    <ThemeUIProvider theme={theme}>
      <YourApp />
    </ThemeUIProvider>
  )
}
4

Use the sx prop

Add the JSX pragma comment and start using the sx prop for theme-aware styling.
Button.jsx
/** @jsxImportSource theme-ui */

export default function Button({ children }) {
  return (
    <button
      sx={{
        bg: 'primary',
        color: 'white',
        px: 4,
        py: 2,
        fontSize: 2,
        borderRadius: 4,
        cursor: 'pointer',
        '&:hover': {
          bg: 'secondary',
        },
      }}
    >
      {children}
    </button>
  )
}
The sx prop automatically references values from your theme object, enabling consistent styling across your entire application.

Core Features

Everything you need to build themeable applications

Constraint-Based Design

Build UIs with design scales for colors, typography, and spacing that enforce consistency.

The sx Prop

Theme-aware styling with inline style objects that reference your design tokens.

Dark Mode Built-In

First-class support for color modes with automatic persistence and media query detection.

Responsive Styles

Mobile-first responsive design with array-based syntax for breakpoint values.

Component Library

Pre-built components for layouts, typography, forms, and UI elements.

TypeScript Support

Strong type inference for themes and style objects with full TypeScript definitions.

Resources

Additional resources to help you succeed

GitHub Repository

View the source code, report issues, and contribute to Theme UI.

Discord Community

Join the community to ask questions and share your projects.

Theme Specification

Learn about the System UI theme specification for interoperability.

Ready to build themeable UIs?

Start building constraint-based design systems with Theme UI today.

Get Started

Build docs developers (and LLMs) love