Skip to content
Browse docs and components

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:

TokenRole
--backgroundThe canvas the page sits on.
--cardCards and panels.
--popoverAnything floating above the page: menus, dialogs, toasts.
--mutedSunken: fields, tracks, wells.
--accentThe hover tint, applied instantly.
--borderThe hairline that divides static structure.
--lineThe 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:

css
: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.

StatusIndicatorTintText 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:

css
: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:

css
.dark {
  --primary: oklch(70% 0.15 155);
}

Light, not paint#

Surfaces are lit rather than coloured, through a handful of utilities foundation.css defines:

UtilityWhat it does
litGrades a card from a few points above its surface down to it.
edgeA 1px inner highlight along the top, where the light catches.
wellAn inner shadow, for fields and tracks pressed into the surface.
floatingThe ring and two-layer shadow of anything that floats.
bg-button-primaryA 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:

VariableValueFor
--duration-fast150msMenus, tooltips, every exit
--duration-standard200msToasts, switches, checkboxes
--duration-modal300msDialogs
--duration-data400msCharts, meters
--ease-standardcubic-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.