Derived themes
When: upfront, when colors and theming are first set up; converting a pile of hand-picked tokens later is a big job. Fine shade tuning can wait.
Before their redesign, every Linear theme needed 98 variables defined by hand. Now a theme is three inputs: accent, background, contrast. A system derives the ~90 tokens from those. Simple enough to maintain, powerful enough to feel personal, constrained enough that users can't make it look horrible. Related: design-color-on-color (shading on known backgrounds).
How
- Inputs:
--base-bg,--accent,--contrast(a 0–1 or low/normal/high scale). Dark vs light falls out of the background's lightness; don't make it a separate theme. - Derive in OKLCH. Surfaces, borders, hover states and text are lightness steps from the background, keeping its hue and a little of its chroma. Text lightness is pushed away from the background by an amount scaled by contrast.
:root {
--base-bg: oklch(0.99 0.005 260);
--accent: oklch(0.6 0.18 270);
--contrast: 1; /* 0.7 low … 1.4 high */
--dir: 1; /* -1 when background is dark */
--bg-raised: oklch(from var(--base-bg) calc(l - 0.02 * var(--dir)) c h);
--border: oklch(from var(--base-bg) calc(l - 0.08 * var(--dir) * var(--contrast)) c h);
--text-2: oklch(from var(--base-bg) calc(l - 0.45 * var(--dir) * var(--contrast)) calc(c * 2) h);
--text-1: oklch(from var(--base-bg) calc(l - 0.8 * var(--dir) * var(--contrast)) c h);
--accent-hover: oklch(from var(--accent) calc(l + 0.05 * var(--dir)) c h);
}
- Components use only derived tokens, never raw inputs or literals.
- Constrain the inputs, not the outputs: clamp background chroma and contrast range so any choice stays readable (check text-1/bg ≥ 7:1 and text-2/bg ≥ 4.5:1 across the range).
Check
- A new theme = 3 values, no other edits
- Random input combos stay legible (spot-check extremes: saturated bg, low contrast, very dark)
- No component references a hard-coded color