Color convention
Every color in the app is written as oklch(). Use a theme token when one fits.
Rules
- Palettes live in
src/config/styles/themes/colors.css.ts. Both areoklch(L C H)with L as a 0 to 1 number, C to 3 decimals and H to 1 decimal. - In styles and components, reference tokens (
themeColors["gray-900"]) instead of literals. If no token fits, writeoklch(). - Translucent and hover or active variants come from
color-mix(in oklch, <color> N%, transparent)or relative color syntax. Do not add a second literal for a tint. - No hex,
rgb(),rgba(),hsl()or named colors (other thantransparentandcurrentColor) insrc/**, except the surfaces below. ESLint enforces this for hex,rgb()andhsl()insrc/**/*.css.ts, and also flags a bareoklch(0 0 0)oroklch(1 0 0)there (use the fixed colors below). - Converting a hex value: compute L, C, H from the linear sRGB value, round, then convert back. Each sRGB channel must land within 1/255 of the original.
Error color
error is rose (hue 12), one token with a light and a dark value. It is for error state only. Its lightness is set by contrast: the lightest value that keeps text at 4.5:1 on the page, on the plate surface and on a 7% wash of itself, in each theme, enforced by src/config/styles/themes/errorContrast.test.ts. The wash is color-mix(in oklch, <error> 7%, transparent), not a second literal. Color is never the only cue: pair it with text and a glyph. The download dialog’s error strip is the reference use.
Fixed colors
Shadows, scrims, masks and highlights are black or white in light and dark mode alike, so no theme token fits them. Import them from src/config/styles/helpers/fixedColors.ts instead of writing oklch(0 0 0) or oklch(1 0 0):
| Export | Value | Use |
|---|---|---|
black | oklch(0 0 0) | Opaque stops in masks, gradients and scrims |
white | oklch(1 0 0) | Opaque highlights |
shade(N) | color-mix(in oklch, oklch(0 0 0) N%, transparent) | Shadows and scrims at N% opacity |
shine(N) | color-mix(in oklch, oklch(1 0 0) N%, transparent) | Highlights and sheens at N% opacity |
shade and shine take a number (a percent) or a string used as written, for an expression such as calc(var(--x) * 100%). mix(N) in helpers/mix.ts is the themed counterpart: the strongest ink at N%, which follows the active theme. A tint that should follow the theme uses mix; one that must not uses shade or shine. An alpha form such as oklch(0 0 0 / 0.25) has no helper yet; ESLint only flags the exact oklch(0 0 0) and oklch(1 0 0) strings in stylesheets. The Foundations/Color story shows them.
Exceptions
These keep hex because the consumer cannot parse oklch(). Keep each in sync with the tokens by hand.
| Surface | File | Reason | Fallback |
|---|---|---|---|
| React Email templates | src/emails/theme.ts | Many email clients (Outlook desktop, older Gmail) ignore oklch() and CSS variables | Hex values, light and dark sets |
| Open Graph image | src/lib/socialCard/ | Satori (next/og) supports hex, rgb and hsl only | Hex INK and GROUND |
| Web app manifest | src/app/manifest.ts | background_color and theme_color are parsed by the OS, which expects sRGB values | Hex |
| App icon | src/app/icon.svg | Icons are rasterized by tools and OS shells that do not all support oklch() | Hex fills with a prefers-color-scheme media query |
theme-color meta | src/app/layout.tsx | Browser chrome support for oklch() in <meta name="theme-color"> is not reliable | Hex per color scheme |
Browser support
oklch() works in Chrome 111, Safari 15.4 and Firefox 113 and newer. Next 15’s default targets include Firefox 111 and 112, which lack it.
The theme tokens carry a hex fallback for those browsers. colors.css.ts repeats the token assignments inside @supports not (color: oklch(0 0 0)), with hex values that oklchToHex derives from the palettes at build time. Edit the oklch() palettes only. The resume print rule has the same fallback.
color-mix(in oklch, ...) tints have no fallback. They were already color-mix(), which Firefox 111 and 112 also lack.