Going further
Theming
The surfaces, the one accent, status pairs, dark mode, light and motion, and how to retheme the whole library.
3 min read · 7 sections
Forme has no theme object and no theme provider. The whole library reads CSS variables from foundation.css, and retheming it means editing those variables. Every component follows, including components you copied weeks ago, because they read variables rather than hard-coded values.
The surfaces#
The names are shadcn's, so an existing shadcn theme slots straight in. What each one means is a rung on one ladder:
| Token | Role |
|---|---|
--background | The canvas the page sits on. |
--card | Cards and panels. |
--popover | Anything floating above the page: menus, dialogs, toasts. |
--muted | Sunken: fields, tracks, wells. |
--accent | The hover tint, applied instantly. |
--border | The hairline that divides static structure. |
--line | The firmer edge of a control, and the ring around a floating panel. |
Neutrals are achromatic. All the colour lives in three places: the accent, the status pairs and the chart series.
One accent#
--primary owns every interactive state — the primary button, selection, links, the focus ring. Everything else is mixed from it: the button gradient, --brand-subtle for selection, --brand-strong for accent text, --ring. Changing one variable moves all of them:
:root {
--primary: oklch(55% 0.17 155); /* a green, and every interactive state follows */
}Status pairs#
A status is never one colour. It travels as three: the solid indicator, the tint it sits in, and the text step that stays readable on that tint.
| Status | Indicator | Tint | Text on tint |
|---|---|---|---|
| Success | --success | --success-subtle | --success-strong |
| Warning | --warning | --warning-subtle | --warning-strong |
| Destructive | --destructive | --destructive-subtle | --destructive-strong |
Dark mode#
Every token is declared once, with both of its values:
:root {
--background: light-dark(oklch(98.75% 0 0), oklch(21% 0 0));
}The .dark class on html (or data-mode="dark") switches color-scheme, and the browser picks the matching half. There is no second block of dark values that can fall out of step with the first. To give one token a different dark value, override it the usual way and it still wins:
.dark {
--primary: oklch(70% 0.15 155);
}Light, not paint#
Surfaces are lit rather than coloured, through a handful of utilities foundation.css defines:
| Utility | What it does |
|---|---|
lit | Grades a card from a few points above its surface down to it. |
edge | A 1px inner highlight along the top, where the light catches. |
well | An inner shadow, for fields and tracks pressed into the surface. |
floating | The ring and two-layer shadow of anything that floats. |
bg-button-primary | A filled control lit from above, with a white inner ring. |
A static card is a hairline plus lit edge and never a shadow. A shadow means something has left the page, which is only true of things that float.
Radius and motion#
Radius is a statement about what an element is: containers 20px, wells 12px, controls 6px, chips 4px. Every rung is a clear step down, so corners share a centre.
Motion follows one rule: feedback is instant, choreography is animated. A hover or a press changes colour on the frame it happens. What animates is geometry and arrival:
| Variable | Value | For |
|---|---|---|
--duration-fast | 150ms | Menus, tooltips, every exit |
--duration-standard | 200ms | Toasts, switches, checkboxes |
--duration-modal | 300ms | Dialogs |
--duration-data | 400ms | Charts, meters |
--ease-standard | cubic-bezier(0.22, 1, 0.36, 1) | Nearly everything |
prefers-reduced-motion collapses every duration to near zero, so motion is already handled for anyone who has asked their system to stop it.
Rules worth keeping#
Colour comes from tokens. Never write a raw #hex, rgb() or a palette class into a component: that value is the one thing no theme, dark mode or rebrand can reach. The theme editor on this site writes exactly these variables, so what you build there pastes straight into foundation.css.