Skip to main content
Theme UI is built on the idea of using design scales for styling. A theme object contains collections of design tokens organized into scales like colors, fonts, and spacing values.

Theme Object Structure

The Theme type defines the complete structure of a Theme UI theme:

Design Scales

Design scales are collections of related values stored as arrays or objects. Theme UI uses these scales to provide consistent styling across your application.

Space Scale

The space scale is used for margin, padding, and other spatial properties:
You can reference these values by index:

Color Scale

Colors can be defined as flat or nested objects:

Font Scales

Other Scales

Nested Scales with __default

Theme UI supports nested scales with a special __default key for shorthand access:
Usage:

Scale Mappings

Theme UI automatically maps CSS properties to theme scales:

Example Theme

Here’s a complete example theme from the Theme UI codebase:

Using the Theme

Wrap your application with ThemeProvider:
Access the theme in components:

Merging Themes

You can merge multiple theme objects:
Theme values are automatically applied when using the sx prop, making it easy to create consistent, theme-aware components.