Skip to main content
The @theme-ui/css package contains the framework-agnostic core logic of Theme UI. It provides the css function and TypeScript types for writing style objects with responsive, theme-aware ergonomic shortcuts.

Installation

When to Use

Use @theme-ui/css when you:
  • Want to use Theme UI’s styling logic without React
  • Need framework-agnostic styling utilities
  • Are integrating with other libraries or frameworks
  • Want to use the css function in vanilla JavaScript
  • Need TypeScript types for Theme UI themes
If you’re using the umbrella theme-ui package or @theme-ui/core, this package is already included.

Exports

Functions

css

Transforms a Theme UI style object into a standard CSS object, resolving theme values and responsive arrays.
Signature:
Features:
  • Theme value lookup from scales (colors, space, fontSizes, etc.)
  • Responsive array values mapped to breakpoints
  • Shorthand property aliases (e.g., px, py, bg)
  • Nested styles and pseudo-selectors
  • Variant references

get

Extracts a value from a deeply nested object using a dot-notation path.
Signature:

Constants

THEME_UI_DEFAULT_KEY

The key used for default values in nested scales.

defaultBreakpoints

Default breakpoint values used when no breakpoints are defined in the theme.

scales

Mapping of CSS properties to their corresponding theme scale.

aliases

Shorthand property aliases.

multiples

Properties that map to multiple CSS properties.

TypeScript Types

The package exports comprehensive TypeScript types:

Theme Type

The main theme interface:

Entry Points

Main Entry Point

/utils

Utility functions for working with themes:

Standalone Usage

You can use @theme-ui/css without React:

Features

Responsive Values

Use arrays for responsive styles:

Negative Values

Use negative numbers or strings with - prefix:

Nested Scales

Support for nested color scales with default values:

Variants

Reference theme variants:

Notes

  • Framework-agnostic - works with or without React
  • No side effects - safe for tree-shaking
  • Requires @emotion/react as a peer dependency
  • Fully typed with TypeScript