Color System
A system is ramps and roles, not a bag of colors. Never estimate a color you can compute, never report a contrast ratio you didn't measure.
Ramps
- One neutral ramp, one accent ramp, and only the status ramps the product actually renders. A
warningramp nothing uses is maintenance for zero pixels. A second accent hue earns its place only when two things must be told apart at a glance. - Build new ramps in
oklch(). Hold one hue end to end, peak chroma mid-ramp, and step finely at the light end (about0.04–0.05in L per step there). Use a color library or script (culori, colorjs.io) — never eyeball steps or copy one chroma number across hues; use the same proportion of each hue's own maximum. - Tint neutrals toward the product's world (warm paper, cool graphite, ink blue) — a few thousandths of chroma, not a visible color. In apps, backgrounds and surfaces stay nearly neutral; the color lives in the accent and the moments. Landing pages can tint further.
- Every step has a job (12-step model): 1–2 backgrounds, 3–5 component fills (rest, hover, pressed), 6–8 borders, 9–10 solid fills, 11–12 text. Don't generate steps no role consumes.
Tokens
- Primitives name a value (
--color-blue-9) and are never used in a component. - Semantic tokens name a job and point at a primitive:
bg,surface,surface-raised,fg,fg-muted,fg-subtle,hairline,accent,accent-hover,on-accent,danger,success. Components use only these (bg-surface,text-fg-muted). Wiring is intailwind-setup§5. - Name semantics by role, never hue or component:
accent-solid, notblue-button. If you haveprimaryfor brand andtext-primaryfor text, rename brand toaccent. - Never borrow a token for another role because its value is right today. A border token used as text color breaks when borders get lighter. Missing role → add the token.
Use
- One color, one meaning across the whole interface. Hues within ~15° in OKLCH count as the same color — keep status hues 15°+ from the accent, or give destructive actions a distinct treatment.
- Color is never the only carrier of meaning. Pair with an icon, label or shape.
- One filled primary action per view. Color goes on the background, not the label; peers stay neutral.
- Three text roles (primary, secondary, muted), not ten near-identical grays.
- Borders are quiet hairlines: the text color at 6–10% alpha.
- No hue gradients on surfaces, gradient text, colored glows, colored shadows, radial color washes or blobs behind content. A gradient is allowed as a small tone shift inside one neutral, or inside a moment (an illustration, a rendered object).
- Gradients interpolate
in oklabby default;in oklchwhen a two-hue gradient goes gray in the middle.
Dark mode
- Not the light ramp reversed. Lower the accent's chroma a little, widen the dark end, and remeasure every pair.
- Depth on dark comes from surface steps and hairlines, not shadows.
- On dark, the primary button can be an off-white from the ramp with dark text, with the accent on a smaller place (selection, key figure).
- One switching mechanism (class or media query), never both.
prefers-contrast: moregets its own value per appearance.
Contrast
| Pair | Minimum |
|---|---|
| Body text | 4.5:1 |
| Large text (≥ 24px, or ≥ 18.67px bold) | 3:1 |
| UI boundaries, focus rings, meaningful icons | 3:1 |
- Measure the foreground against the background it actually renders on (cards, overlays, images), including alpha. Text on
/50orrgba(needs the rendered result measured. - White on most Tailwind
500fills fails 4.5:1. Measure, don't assume. - A contrast fix changes lightness, not hue.
- When a pair fails in someone else's design, report the pair, the measured ratio and the threshold, and leave the colors alone unless asked.
Wide gamut
Declare the sRGB value first, then the vivid P3 one inside @media (color-gamut: p3). Never ship an oklch() chroma beyond sRGB with no fallback.
Native
React Native doesn't parse oklch() everywhere — compute hex/rgb from the OKLCH ramp at build time and put those in tailwind.config.js. Same roles, same names.
Before you finish
| Pattern | Fix |
|---|---|
Hex/rgb(/oklch( literal or bg-blue-600 in a component | Semantic token |
One oklch() in an otherwise hex codebase | Keep the established notation unless migrating |
| Semantic name containing a hue or component | Rename by role |
| Two accent-ish hues competing | One accent, more steps |
| Status hue within 15° of the accent | Move it |
| Dark theme = light ramp reversed | Rebuild the dark end, remeasure |
Tokens under both .dark and prefers-color-scheme | Pick one |
text-white on a 500 fill | Measure; darken the fill or use dark text |