Search documentation

Search pages, components, blocks, styles and colours.

Get started
Skip to content

Colors

PreviousNext

Eight surface levels and six colour roles, each set by a hue and a strength, with every state AA in light and dark.

Installation

The surface and colour tokens ship with the foundations:

bunx --bun fabricator-ui@latest add foundations

Pick your colours

Every colour in the components comes from two places: the surfaces, eight elevation levels from the page to the top of a stack, and six colour roles. Each is one base colour held by two variables, a hue (--surface-hue, --<role>-hue, in OKLCH degrees) and a strength (--surface-chroma, --<role>-chroma). At strength 0 they are neutral: that is the default for the surfaces, primary and secondary, so the components stay black and white until you pick a colour.

Hue
0°
Strength
0%
Preview
Deployments
apiReady2m ago
webBuilding
x
workerFailed
api is live on production
Surface levels, with muted text
Aa1 4.5:1
Aa2 4.6:1
Aa3 4.7:1
Aa4 4.7:1
Aa5 4.7:1
Aa6 4.7:1
Aa7 4.7:1
Aa8 4.7:1
Pick the surface or a role, then a preset or your own colour: hue sets --surface-hue or --<role>-hue, and strength sets the matching chroma (100% is 0.04 for surfaces, and for roles the most the hue can hold with every token inside sRGB). Primary and secondary take any hue; info stays blue, success green, warning orange to yellow and destructive red to orange. Every tab shares the preview, so you see the whole interface change; switch its theme above it. The numbers are WCAG contrast on the page. The choice applies to the whole site and is saved in this browser.
globals.css
:root {
  --surface-hue: 0;
  --surface-chroma: 0;
  --primary-hue: 0;
  --primary-chroma: 0;
  --secondary-hue: 0;
  --secondary-chroma: 0;
  --info-hue: 260;
  --info-chroma: 0.18;
  --success-hue: 150;
  --success-chroma: 0.13;
  --warning-hue: 70;
  --warning-chroma: 0.1;
  --destructive-hue: 25;
  --destructive-chroma: 0.19;
}

/* Let the theme tokens follow the surfaces and the roles. */

:root {
  --background: var(--surface-1);
  --card: var(--surface-3);
  --popover: var(--surface-3);
  --sidebar: var(--surface-2);
  --muted: oklch(calc(0.967 - var(--surface-chroma) * 0.5) calc(var(--surface-chroma) * 0.4) var(--surface-hue));
  --muted-foreground: oklch(calc(0.556 - var(--surface-chroma) * 0.4) 0 0);
  --primary: oklch(calc(0.205 + 0.275 * min(1, var(--primary-chroma) / 0.06)) calc(var(--primary-chroma) * min(1, var(--primary-chroma) / 0.06)) var(--primary-hue));
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(calc(0 + 0.48 * min(1, var(--secondary-chroma) / 0.06)) calc(var(--secondary-chroma) * min(1, var(--secondary-chroma) / 0.06)) var(--secondary-hue) / calc(0.08 + 0.04 * min(1, var(--secondary-chroma) / 0.06)));
  --secondary-foreground: oklch(calc(0.205 + 0.245 * min(1, var(--secondary-chroma) / 0.06)) calc(var(--secondary-chroma) * 0.85 * min(1, var(--secondary-chroma) / 0.06)) var(--secondary-hue));
  --destructive: oklch(calc(0.205 + 0.275 * min(1, var(--destructive-chroma) / 0.06)) calc(var(--destructive-chroma) * min(1, var(--destructive-chroma) / 0.06)) clamp(10, var(--destructive-hue), 50));
  --sidebar-primary: oklch(calc(0.205 + 0.275 * min(1, var(--primary-chroma) / 0.06)) calc(var(--primary-chroma) * min(1, var(--primary-chroma) / 0.06)) var(--primary-hue));
  --sidebar-primary-foreground: oklch(0.985 0 0);
}

.dark {
  --background: var(--surface-1);
  --card: var(--surface-3);
  --popover: var(--surface-3);
  --sidebar: var(--surface-2);
  --muted: oklch(0.235 calc(var(--surface-chroma) * 0.85) var(--surface-hue));
  --primary: oklch(calc(0.97 - 0.23 * min(1, var(--primary-chroma) / 0.06)) calc(min(var(--primary-chroma), 0.13) * min(1, var(--primary-chroma) / 0.06)) var(--primary-hue));
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(calc(1 - 0.26 * min(1, var(--secondary-chroma) / 0.06)) calc(min(var(--secondary-chroma), 0.13) * min(1, var(--secondary-chroma) / 0.06)) var(--secondary-hue) / calc(0.25 - 0.03 * min(1, var(--secondary-chroma) / 0.06)));
  --secondary-foreground: oklch(calc(0.97 - 0.08 * min(1, var(--secondary-chroma) / 0.06)) calc(min(var(--secondary-chroma), 0.045) * min(1, var(--secondary-chroma) / 0.06)) var(--secondary-hue));
  --destructive: oklch(calc(0.97 - 0.23 * min(1, var(--destructive-chroma) / 0.06)) calc(min(var(--destructive-chroma), 0.13) * min(1, var(--destructive-chroma) / 0.06)) clamp(10, var(--destructive-hue), 50));
  --sidebar-primary: oklch(calc(0.97 - 0.23 * min(1, var(--primary-chroma) / 0.06)) calc(min(var(--primary-chroma), 0.13) * min(1, var(--primary-chroma) / 0.06)) var(--primary-hue));
  --sidebar-primary-foreground: oklch(0.205 0 0);
}

The strength slider is a share of the most the colour can hold: 0.04 for the surfaces, and for a role the most chroma its hue can take with every fill, text and border inside sRGB. That limit depends on the hue: a blue can go much further than a cyan before it leaves the gamut.

Surfaces

The ladder

Each level pairs a background with a shadow: bg-surface-N shadow-surface-N. In light mode, levels 1 and 2 are off-white and everything from level 3 up is white (tinted, when you set a base colour): the shadow alone carries the elevation. In dark mode, each level is a step lighter than the one below, and the shadow adds a faint top highlight and ring.

0
Sign in
1
Page
2
Sidebar
3
Card, popover
4
Active tab
5
Dialog
6
Above a dialog
7
Menu in a dialog
8
Top
Switch the theme to compare. Level 0 lies below the page: white in light, a step darker in dark. Neutral light flattens to white from level 3 and lets the shadow carry the elevation; dark lifts each level a step lighter. With a base colour, every level in both themes carries the tint.

Surfaces have no borders. Every surface shadow starts with a 1px ring, which draws the edge.

Level 0 sits below the page, for a screen that stands alone with nothing raised around it, such as sign in: bg-surface-0 is white in light mode and a step darker than the page (oklch(0.175)) in dark. It takes the base colour more lightly than the page and has no shadow.

Base colour

Every surface derives from one base colour: --surface-hue and --surface-chroma (from 0 to 0.04). Both are 0 by default, which gives the neutral ladder above. Set them with the Surface tab of the picker. Each level takes a share of the chroma:

  • Light mode tints every level, like dark mode: the page takes 44% of the chroma (about oklch(0.962 0.018) at full strength) and the top level 21.5%. Colour needs room below white, so as the tint grows the ladder settles into a band just below white (0.962 to 0.981 at full strength), still lighter level by level, and muted-foreground darkens with it to stay AA on the page.
  • Dark mode carries the tint: level 1 takes 90% of the chroma, and each level above takes a little less, so the top of the ladder stays calm.

At full strength, every level stays inside sRGB for any hue. Text stays AA wherever it was AA on the neutral ladder. The opaque bg-selected and bg-muted fills follow the tint too.

/* light */
--surface-1: oklch(
  calc(0.985 - var(--surface-chroma) * 0.575) calc(var(--surface-chroma) * 0.44)
    var(--surface-hue)
);
/* dark */
--surface-1: oklch(0.205 calc(var(--surface-chroma) * 0.9) var(--surface-hue));

Where each level goes

WorkspaceThreadsAgents
OverviewLogs
Runs this week128 runs, 4 failed
Rerun failed jobs?Four jobs will run again.
Page (1), sidebar (2), card (3), active tab (4) and a dialog (5) over it. No borders: every edge is the shadow's 1px ring.
ElementClasses
Pagebg-background (surface 1)
Sidebarbg-sidebar (surface 2); an inset main area is bg-surface-2 shadow-surface-2
Raised cardbg-surface-3 shadow-surface-3
Popover, dropdown, select, combobox, context menu, hover cardbg-surface-3 shadow-surface-3 rounded-xl
Active tabbg-surface-4 shadow-surface-4
Dialog, alert dialogbg-surface-5 shadow-surface-5 rounded-xl
Sheet, drawerbg-surface-3 shadow-surface-3
TooltipInverted: bg-foreground text-background

Overlays behind dialogs and sheets are bg-black/40, and bg-black/80 in dark mode.

Interaction overlays

Hover and press states are translucent overlays, so they work on any surface.

bg-hoverLit rows, ghost hover
bg-activePressed, selected
bg-selectedSolid selection
bg-tintTranslucent fill
TokenLightDarkUse
bg-hover4% black6% whiteHover, the Fluid Hover highlight
bg-active7% black10% whitePressed, selected rows, toggled on
bg-selectedSolid greySolid greySelection that must stay opaque
bg-tint, bg-tint-hover8%, 6.5% black25%, 20% whiteTranslucent fills

Colour roles

Each role is one base colour, and every token it needs is calculated from it.

RoleWhere it shows
primaryPrimary buttons, links, checked checkboxes and radios, switches that are on, progress bars, slider ranges, selected days
secondarySecondary buttons, as a soft tint
infoInfo alerts, badges and toasts
successSuccess alerts, badges and toasts
warningWarning alerts, badges and toasts
destructiveDestructive buttons and menu items, invalid fields and their messages, error alerts, badges and toasts

Hues

Primary and secondary take any hue. The statuses keep to their family, so a status always reads as what it is:

RoleHuesTonesDefault
info215–275Sky, blue, indigo260 (blue)
success125–175Lime, green, emerald150 (green)
warning45–100Orange, amber, yellow70 (amber)
destructive10–50Rose, red, orange25 (red)

The CSS clamps a status hue to its range, so a hand-written --warning-hue: 300 stays yellow.

Role tokens

Every role has the same tokens, so a component can carry any of them:

TokenUtilityUse
--<role>bg-<role>, text-<role>, fill-…The fill: buttons, checked controls, icons and dots
--<role>-foregroundtext-<role>-foregroundText on the fill
--<role>-texttext-<role>-textColoured text on any surface
--<role>-borderborder-<role>-border, ring-…Hairlines
--<role>-surface-1 … 8bg-<role>-surface-1 … 8Tinted surfaces; pair with shadow-surface-N
<div className="rounded-xl bg-success-surface-3 p-4 text-success-text shadow-surface-3">
  Deployed to production.
</div>

Secondary is the soft role, as in shadcn: its fill is a translucent tint (8% black in light, 25% white in dark, when neutral), and its foreground is its text colour.

How the values are made:

  • Light mode. The fill starts at the foreground colour and, as the chroma grows to 0.06, moves to a mid-tone (lightness 0.48) and takes on the colour. Past that point only the chroma grows. Text on it is white. The text colour moves from the foreground to lightness 0.45.
  • Dark mode. The fill starts near white and moves to a light tint (lightness 0.74, chroma up to 0.13), with dark text on it. The text colour settles at lightness 0.85.
  • Surfaces. The same eight levels as the neutral ladder, tinted: light mode lifts towards white, dark mode a step lighter per level, and the chroma tapers as the levels rise.

States

One rule covers every role, so the states stay consistent across the library. Because the states are opacity steps of the fill, they also work with any other palette.

StateSolidSoft
Restbg-<role> text-<role>-foregroundbg-<role>/12 text-<role>-text
Hoverhover:bg-<role>/90hover:bg-<role>/16
Pressedactive:bg-<role>/80active:bg-<role>/20
Disableddisabled:opacity-50disabled:opacity-50
Focusfocus-visible:ring-1 focus-visible:ring-ringfocus-visible:ring-1 focus-visible:ring-ring

Statuses use a third form, from the Alert: a neutral panel with an icon in the fill colour (low contrast), or bg-<role>-surface-1 dark:bg-<role>-surface-3 with ring-<role>-border and the description in text-<role>-text (high contrast). Badges always use the tinted form.

Error and destructive

error is another name for destructive. <Alert variant="error"> and <Badge variant="error"> look the same as their destructive variants, and toasts of type error use the destructive colour.

Defaults

RoleHueChroma
primary00 (neutral)
secondary00 (neutral)
info2600.18
success1500.13
warning700.1
destructive250.19

Focus

Focus is a 1px blue ring with no offset, the same in both themes and in every role, so it stays visible whatever colours you pick: focus-visible:ring-1 focus-visible:ring-ring. The colour is also available as --focus-ring.

Contrast

The tests check the surfaces and every role around the colour wheel, in light and dark:

  • Text is AA on every surface level, tinted or not. Muted text is AA on every level in light, and up to dialogs (level 5) in dark, where the top levels keep 3:1.
  • A role's foreground on its fill is at least 4.5:1 at rest and on hover. Pressed, shown only while the pointer is down, keeps 3:1.
  • A role's text is at least 4.5:1 on every neutral surface, every tinted surface at full strength, and its own ladder.
  • A role's fill is at least 3:1 on all of them, for icons and checked controls.
  • Secondary text is at least 4.5:1 on its soft fill, on the levels a button sits on (page to dialog).
  • Surfaces, fills, text and borders stay inside sRGB at every strength the picker offers. The light tinted role ladders can leave sRGB near the top, where screens clip them towards white.

In your project

The fabricator preset writes the theme tokens it shares with other registries (background, card, popover, sidebar, muted, muted-foreground, primary, primary-foreground, secondary, secondary-foreground and destructive) as plain colours at the defaults, because the CLI only maps plain colours to Tailwind utilities. To use your own colours, set the variables and point those tokens at the surfaces and the roles, as the CSS under the picker does. Tailwind keeps the utilities the preset already mapped, so bg-background and bg-primary keep working.

:root {
  --surface-hue: 145;
  --surface-chroma: 0.022;
  --primary-hue: 277;
  --primary-chroma: 0.2975;
}

The other tokens (--surface-N, --<role>-text, --<role>-surface-N, --info, …) always follow the variables.

Tokens

VariableUtility
--surface-hue, --surface-chromaThe surfaces' base colour (see Base colour)
--surface-0bg-surface-0: below the page, for screens that stand alone
--surface-1 … 8bg-surface-1 … bg-surface-8
--shadow-1 … 8shadow-surface-1 … shadow-surface-8
--hoverbg-hover
--activebg-active
--selectedbg-selected
--tintbg-tint
--tint-hoverbg-tint-hover
--focus-ringring-focus-ring
--<role>-hue, --<role>-chromaA role's base colour (see Hues)
--<role>, --<role>-foreground, …See Role tokens

These are new names: the theme tokens such as background, card and border keep their meaning, so components from other registries still fit in.