02 — Get started
Theming
The components use semantic tokens. A token names the use of a color, not the color. Change a token, and all the components change.
Tokens
Each token is a CSS variable, and a Tailwind CSS utility: --primary gives bg-primary, text-primary and border-primary.
| Token | Use |
|---|---|
canvas | The page. |
surface / surface-muted | The box of a control or a card, and a quieter one. |
overlay | What opens over the page: a popover, a menu, a dialog. |
hover / selected | An item under the pointer, and the selected item. |
ink / ink-muted / ink-subtle | The text, in three weights. Subtle is for placeholders and icons. |
line / line-strong | Dividers and the edge of a region. |
primary / primary-hover / on-primary | The main action, and its text. |
primary-soft / primary-line / primary-ink | A quiet fill, a border and text in the primary colour. |
danger / success / warning / info | The states. Each one has -soft, -line, -ink and -solid. |
tone-{gray, blue, cyan, teal, green, amber, orange, red, pink, violet} | The palette for tags and charts, with the same four roles, plus -fill for an avatar and -tint, -tint-ink and -tint-dot for a badge. |
ring | The focus ring. |
Change a token
Write the new value in your CSS file, after the theme block. Give a value for the light theme and for the dark theme.
:root {
--primary: oklch(0.55 0.2 260);
--primary-hover: oklch(0.51 0.21 260);
--primary-ink: oklch(0.47 0.2 260);
--ring: oklch(0.55 0.2 260);
}
.dark {
--primary-ink: oklch(0.78 0.12 260);
--ring: oklch(0.7 0.15 260);
} Dark theme
The dark theme starts when an ancestor has the dark class. Put the class on the html element. The components have no dark: classes, because the tokens
change.
Contrast
The default tokens obey WCAG 2.2 in the two themes:
- A text has a contrast of 4.5:1 or more on its surface.
- The focus ring has a contrast of 3:1 or more.
When you change a token, check these pairs again.
Reduced motion
When the system asks for reduced motion, the overlays open and close with no animation.