Skip to content

Theming

Swap a product's palette and font families, and nothing else.

Foundation holds two kinds of token. A product sets the first kind: the colours and typefaces that make it recognisable. The second kind is the structure every Khaeli product shares, and no product changes it.

What a product sets

The --primary family, the --tint-* markers, the --chart-* series and the three font families, and nothing else:

Primary family
--primary--primary-foreground--primary-hover--primary-subtle--primary-subtle-border--link
Tints
--tint-mint--tint-mint-foreground--tint-peach--tint-peach-foreground--tint-sky--tint-sky-foreground--tint-blue--tint-blue-foreground--tint-pink--tint-pink-foreground--tint-lavender--tint-lavender-foreground
Charts
--chart-1--chart-2--chart-3--chart-4--chart-5--chart-cat-1--chart-cat-2--chart-cat-3--chart-cat-4--chart-cat-5
Font families
--font-body--font-display--font-code

Everything else that carries the brand follows the primary by itself: the focus ring, checked controls, links in light and the shadow of a lifted card.

Try another primary

The panel below is a scope with its own primary family. Choose a primary and the components inside take it; the page around the panel, the Copy button included, keeps the default. The three alternatives are examples made for this page, not Khaeli brand colours.

Primary
BetaFoundation
Storage used
x
app/globals.css
:root {
  --primary: #462cf2;
  --primary-foreground: #ffffff;
  --primary-hover: #3b22db;
  --primary-subtle: #f1effd;
  --primary-subtle-border: #e0dcf7;
}

.dark {
  --primary: #5b45f5;
  --primary-foreground: #ffffff;
  --link: #9a8cff;
  --primary-hover: #6b57f7;
  --primary-subtle: rgb(from var(--primary) r g b / 0.2);
  --primary-subtle-border: rgb(from var(--primary) r g b / 0.38);
}
PrimaryWhite on the fill, lightWhite on the fill, dark
Default7.23:15.81:1
Teal7.32:15.21:1
Blue7.31:15.16:1
Plum6.75:15.68:1

A product writes the block on :root and .dark, and everything that follows the primary follows by itself. The demo sets the same tokens on its panel instead, so it also declares again what foundation derives from them, because a custom property that reads var(--primary) takes its value where it is declared: --control-checked, --control-checked-foreground, --ring, --link, --tone-indigo, --sidebar-primary, --sidebar-ring, --shadow-card-lift, --shadow-focus, --shadow-fab.

The override block

Write the override in the product's stylesheet, after foundation, on :root for light and on .dark for dark. Start from foundation's values, change what the brand needs and delete the lines you leave alone:

app/globals.css
:root {
  --primary: #462cf2;
  --primary-foreground: #ffffff;
  --primary-hover: #3b22db;
  --primary-subtle: #f1effd;
  --primary-subtle-border: #e0dcf7;
  --tint-mint: #e3f1e4;
  --tint-mint-foreground: #2e5a34;
  --tint-peach: #fae9df;
  --tint-peach-foreground: #6b3a1e;
  --tint-sky: #dff1f1;
  --tint-sky-foreground: #1a5556;
  --tint-blue: #e2eefa;
  --tint-blue-foreground: #254a66;
  --tint-pink: #fbe7e9;
  --tint-pink-foreground: #6e3a42;
  --tint-lavender: #eeebfe;
  --tint-lavender-foreground: #3f28c9;
  --chart-1: oklch(0.8 0.1 275.5);
  --chart-2: oklch(0.65 0.2 275.5);
  --chart-3: oklch(0.56 0.25 275.5);
  --chart-4: oklch(0.486 0.269 275.5);
  --chart-5: oklch(0.4 0.22 275.5);
  --chart-cat-1: oklch(0.52 0.25 275.5);
  --chart-cat-2: oklch(0.58 0.12 185);
  --chart-cat-3: oklch(0.64 0.16 60);
  --chart-cat-4: oklch(0.58 0.21 350);
  --chart-cat-5: oklch(0.56 0.14 240);
  --font-body: var(--font-inter, "Inter Variable"), "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-code: var(--font-geist-mono, "Geist Mono Variable"), ui-monospace, monospace;
}

.dark {
  --primary: #5b45f5;
  --primary-foreground: #ffffff;
  --link: #9a8cff;
  --primary-hover: #6b57f7;
  --primary-subtle: rgb(from var(--primary) r g b / 0.2);
  --primary-subtle-border: rgb(from var(--primary) r g b / 0.38);
  --tint-mint: #16301b;
  --tint-mint-foreground: #9fdcaa;
  --tint-peach: #3a2417;
  --tint-peach-foreground: #f2bf9c;
  --tint-sky: #102f30;
  --tint-sky-foreground: #92d6d6;
  --tint-blue: #152a3e;
  --tint-blue-foreground: #a3c8ea;
  --tint-pink: #3a1d22;
  --tint-pink-foreground: #f0b1ba;
  --tint-lavender: #24204a;
  --tint-lavender-foreground: #c2b8ff;
  --chart-1: oklch(0.8 0.1 275.5);
  --chart-2: oklch(0.65 0.2 275.5);
  --chart-3: oklch(0.56 0.25 275.5);
  --chart-4: oklch(0.486 0.269 275.5);
  --chart-5: oklch(0.4 0.22 275.5);
  --chart-cat-1: oklch(0.68 0.17 275.5);
  --chart-cat-2: oklch(0.74 0.12 185);
  --chart-cat-3: oklch(0.78 0.15 65);
  --chart-cat-4: oklch(0.72 0.17 350);
  --chart-cat-5: oklch(0.72 0.12 240);
}
  • Set a colour in both blocks. A value written on :root after foundation also wins in dark, because :root and .dark weigh the same and the later rule wins.
  • Keep text on the primary at 4.5:1 or better, and the primary at 3:1 or better against the canvas, so that focus rings and checked controls stay visible.
  • --font-display follows --font-body until you set it. Loading the font files is the product's part; foundation loads Inter and Geist Mono only.
  • Adding foundation again resets the palette in the stylesheet. Put the override back after it.

What never changes

Components are drawn on the structural tokens, so a product that changes one no longer lines up with the others:

  • the radius ladder, from the 6px chip to the 16px tray;
  • the 30px control height;
  • the type scale and its two weights;
  • the spacing unit;
  • the motion durations and eases;
  • the neutrals and the status colours.