Visual design · Step 3 · 8 min read
Building a colour palette in OKLCH
Why OKLCH is the right colour space for interface design, and how to build a three-layer palette — neutral scale, accent scale, and semantic scale — that holds up in dark mode and meets contrast requirements.
Colour is the second element that builds hierarchy. This lesson builds a palette that holds up in dark mode.
What you'll be able to do after reading:
- Explain what OKLCH is and why it is better for interface design than HSL
- Read and write an OKLCH value in CSS
- Build a neutral scale with five stops
- Apply the three-layer model — neutral scale · accent scale · semantic scale — to any project
- Identify which OKLCH value to adjust when a swatch looks too bright or too saturated
1. The problem with HSL
You may already work in HSL. It is more readable than RGB: hsl(240, 60%, 50%) tells you something is blue-toned at medium lightness, while rgb(51, 102, 191) does not. But HSL has a problem: its lightness axis lies.
Take two colours with the same HSL lightness — hsl(240, 100%, 50%) (blue) and hsl(60, 100%, 50%) (yellow). On screen, the yellow looks far brighter. Yellow light stimulates the eye more than blue light at the same energy. HSL ignores this. Its "50% lightness" is a geometric midpoint in the hex-RGB cube, not a perceptual measurement.
This matters when you are building a palette. If you pick five neutral stops at L 10%, 30%, 50%, 70%, 90% in HSL and check their contrast against white, they do not give you evenly spaced contrast against white. The mid-stop at 50% has an unpredictable contrast from the HSL number alone.
If you have already worked through Colour and contrast, you know the basics of how contrast is calculated. What OKLCH adds is a colour space where the numbers mean what they look like.
2. What OKLCH is
OKLCH is a perceptually uniform colour space. Equal steps in its lightness axis produce roughly equal-looking changes on screen. If you raise L from 0.50 to 0.55, the result is about as much brighter as going from 0.60 to 0.65.
An OKLCH value has three parts:
| Letter | What it describes | Range |
|---|---|---|
| L | Lightness — 0 is black, 1 is white | 0 to 1 |
| C | Chroma — amount of colour; 0 is grey | 0 to ~0.4 (varies by hue) |
| H | Hue — angle around the colour wheel | 0° to 360° |
In CSS, you write it as oklch(L C H). Gale Blue is oklch(0.52 0.16 240) — medium lightness, moderate chroma, blue hue.
Browser support for oklch() is 95% globally as of late 2026, covering Chrome 111+, Firefox 113+, Safari 15.4+ and Edge 111+ (caniuse.com). For older browsers, you can include an rgb() fallback first and let the cascade pick the best one:
/* Fallback first, then oklch() */
color: rgb(50, 90, 180);
color: oklch(0.52 0.16 240);
The mathematical foundation is Björn Ottosson's OKLAB model (2020), which corrects the hue-shift and chroma-uniformity problems in earlier perceptual spaces (Ottosson, A perceptual color space for image processing). OKLCH uses OKLAB's axes but presents them in polar coordinates (L, C, H), which are easier to reason about than the Cartesian a and b axes.
3. The three-layer model
A palette is a structure, not a list of colours you like. It has three layers, each with a specific job:
| Layer | Purpose | Contents |
|---|---|---|
| Neutral scale | Surfaces, dividers, text | 5 stops from near-white to near-black |
| Accent scale | Interactive elements, highlights | 1–2 stops of the brand colour |
| Semantic scale | Status and feedback | Green, amber, red, blue |
Neutrals do most of the work in any interface: backgrounds, card surfaces, borders, label text. The accent appears sparingly — the main action button, a link, a selected state. Semantic colours carry meaning. Using a semantic colour for decoration (a green header purely for style) breaks the system: when real status appears, the colour is already diluted.
4. Building the neutral scale
Five stops cover most interfaces. Each stop has a job, not just a name:
| Stop | OKLCH | Job in Gale Console |
|---|---|---|
| N10 | oklch(0.97 0.01 240) |
Page background, card and panel base |
| N20 | oklch(0.88 0.015 240) |
Input background, dividers, table stripes |
| N40 | oklch(0.60 0.02 240) |
Placeholder text, disabled text |
| N70 | oklch(0.30 0.02 240) |
Secondary text, captions |
| N90 | oklch(0.14 0.015 240) |
Primary text, icons |
The hue angle is 240° across all five stops — the same hue as Gale Blue. The chroma stays very low (C 0.01–0.02). This slight tint at the brand hue is what makes the neutrals read as cool-toned. Without it, they are flat grey with no relation to the accent. Run the numbers without it (C=0) and the palette loses its coherence — the grey background and the blue button look like they are from different designs.
One thing to avoid: steps that are too close together. N10 and N20 differ by L 0.09; that is enough for most displays to tell them apart. If you add N15 at oklch(0.92 0.01 240), it will read as nearly identical to N10 on many screens in ambient light.
To set the whole scale as CSS custom properties:
:root {
--vd-n10: oklch(0.97 0.01 240);
--vd-n20: oklch(0.88 0.015 240);
--vd-n40: oklch(0.60 0.02 240);
--vd-n70: oklch(0.30 0.02 240);
--vd-n90: oklch(0.14 0.015 240);
}
5. Accent and semantic scales
Accent scale. Gale's primary colour is oklch(0.52 0.16 240). L 0.52 is chosen so the blue passes WCAG AA for normal text on a white background. Contrast ratios and WCAG covers how that is calculated and verified. For selected rows and chips, Gale Blue Surface at oklch(0.95 0.03 240) provides a tinted background without competing with text.
:root {
--vd-blue-surf: oklch(0.95 0.03 240);
--vd-blue: oklch(0.52 0.16 240);
}
Semantic scale. Four hues, four meanings. The L values are chosen so all four sit near the same perceived brightness — none shouts louder than the others when placed side by side:
:root {
--vd-green: oklch(0.55 0.17 145); /* success */
--vd-amber: oklch(0.65 0.18 70); /* warning */
--vd-red: oklch(0.52 0.22 25); /* danger */
/* blue = --vd-blue (informational) */
}
The palette exists. The next step is to give each colour a function: what is surface, what is primary, what is status.
6. Common mistakes
- Choosing neutrals in HSL at round numbers. "50% lightness" in HSL is not mid-contrast. Use OKLCH or verify the contrast against white after picking.
- Chroma too high in the neutral scale. C above 0.03 makes a neutral read as a tinted colour, not a neutral. Gale's neutrals stay at C 0.01–0.02.
- Too many stops. Five neutrals cover almost every interface. Adding N15 and N25 means your team will use adjacent stops interchangeably.
- Semantic colours as decoration. Green means success in this system. If you also use it for a "new feature" badge, the signal is gone when a real status badge appears.
- No fallback for older browsers.
oklch()reaches 95% global support — not 100%. For anything that must work on older mobile browsers, include anrgb()fallback.
7. Try it
The exercise uses the Gale palette swatches in the figure above.
- Open the figure with the three-layer palette. Look at the five neutral stops from N10 to N90. Cover the labels with your hand. Can you tell them apart without the labels?
- Now look only at the semantic scale (green, amber, red, blue). The four colours should feel about equally bright. If one stands out as clearly brighter or darker, write down which one and what you would adjust: raise or lower its L value?
- Take any app you use at work. Find its primary interactive colour (the main button or link). Open browser DevTools and pick the hex value. Paste it into the CSS.land OKLCH tool to convert it to OKLCH. What is the L value? Is it close to 0.52 (Gale Blue) or higher/lower? What does that tell you about the contrast it has against white?
You are done when you have an OKLCH value for the app's primary colour and can say whether it would pass AA contrast on a white background.
8. If you already practise
- Compare two palette tools: one that works in HSL (like Tailwind's Palette generator) and one that works in OKLCH (like oklch.com). Generate a neutral scale in each. Convert both to OKLCH and compare the L steps — the HSL tool's steps are rarely even.
- Read Björn Ottosson's original post on OKLAB (bottosson.github.io/posts/oklab/). The hue-uniformity graph (where hue stays stable as chroma changes) explains why OKLCH behaves better than HSL when you shift saturation.
- Build your own three-layer palette in OKLCH for a product you are working on. Keep one rule: the neutral chroma must stay at or below 0.02.
Checklist
Learn more
- MDN: oklch() — syntax reference and browser support table
- W3C CSS Color 4 — the oklch notation — the spec definition and the relationship to OKLAB
- Björn Ottosson, A perceptual color space for image processing (2020) — the mathematical motivation
- caniuse: oklch() — current browser support
- CSS.land OKLCH picker — convert from hex/HSL and explore the colour space
Books, courses and videos to go deeper
- Interaction of ColorJosef AlbersBook · Yale University Press, pocket edition, 2006 · — the foundational argument for why colour is relative: how the same colour looks different depending on what surrounds it (Amazon)
- CSS in DepthKeith GrantBook · Manning, second edition, 2023 · — practical CSS colour, including custom properties and the cascade
Book links go to Amazon. As an Amazon Associate I earn from qualifying purchases, at no extra cost to you.
Related
Semantic colour and state · Colour and contrast · Variable fonts and performance · Dark mode that actually works