Theming and density

Colors, radius, type and spacing are design tokens, published as CSS variables. A theme and a density are sets of token values that you choose with an attribute on any element, and every component follows them, in React and in Figma.

Try the switches at the top of this page: they set the same attributes on this site.

Themes

<html data-theme="light">
<html data-theme="dark">

Without data-theme, the theme follows the system preference (prefers-color-scheme). The attribute works on any element, so a panel can be dark inside a light page:

<aside data-theme="dark">…</aside>

Density

Density is a property of the application, not of a component. It changes control heights, padding, gaps, font sizes, line heights and icon sizes together:

<html data-density="compact">
<html data-density="standard">
<html data-density="comfortable">

Without data-density, density is standard. Like themes, it applies to the subtree of the element that sets it, so a dense table can sit in a standard page.

A component's size (sm, md, lg) stays local and combines with density: a medium Button is 24 px high in compact, 32 px in standard and 40 px in comfortable. Compact controls are at least 24 px high, the WCAG 2.2 target size minimum.

Tokens

Variables are named --ue- and the token's path with dashes, for example:

Token Variable
color.action.primary.bg --ue-color-action-primary-bg
color.fg.muted --ue-color-fg-muted
radius.control --ue-radius-control
control.height.md --ue-control-height-md

Tokens come in four collections: primitives (the raw palette and scales), theme (semantic colors and type, in light and dark), density (sizes, in three densities) and styles (composite typography and shadows). Components only use semantic tokens, never primitives, so changing a semantic token changes every component that uses it.

Use the variables in your own CSS to match the Engine:

.panel {
  background: var(--ue-color-bg-surface);
  color: var(--ue-color-fg-default);
  border-radius: var(--ue-radius-control);
  box-shadow: inset 0 0 0 1px var(--ue-color-border-default);
}

The tokens are also published without components: @uiuxengine/tokens/tokens.css for CSS, and DTCG files in @uiuxengine/tokens/dtcg/ for other tools.

Changing tokens

Override a semantic variable after the Engine's stylesheet. This selector applies the value in every theme, including the system one:

:root:not([data-theme]),
[data-theme] {
  --ue-color-action-primary-bg: #6d28d9;
  --ue-color-action-primary-bg-hover: #5b21b6;
  --ue-color-action-primary-bg-pressed: #4c1d95;
}

To set a value for one theme only, use [data-theme="dark"], and for the system dark theme, :root:not([data-theme]) inside @media (prefers-color-scheme: dark).

CSS overrides change your app, not your Figma file, which keeps the Engine's tokens. Custom themes that sync to Figma as variable modes are planned.

Changing a component's CSS

Generated component CSS wraps every variant and state condition in :where(), so a component's root rules have the specificity of one class, and its part rules one class and one attribute. Your own rules with the same specificity, loaded later, win:

.ue-button {
  border-radius: 999px;
}

.ue-button > [data-part="label"] {
  letter-spacing: 0.01em;
}

Part names, such as label, are stable: they're listed in each component's design, appear as data-part in the DOM, and are stored on the matching Figma layers. Like token overrides, component CSS doesn't reach Figma. To change a component everywhere, change its definition: see Your own components.