Book a call

WritingFoundations & tokensPart 3 of 6 in Tokens in practice

How to build an accessible colour palette in OKLCH

HSL promises that colours with the same lightness look equally light. They don't, and that's why so many palettes fail contrast checks. OKLCH fixes it. A method for building even, accessible ramps, with every number computed.

On this pageWhy HSL palettes look uneven
  1. Why HSL palettes look uneven
  2. What OKLCH is, in plain terms
  3. Step 1: Pick a hue and peak chroma for each family
  4. Step 2: Use one lightness curve for every ramp
  5. Step 3: Shape chroma so it peaks in the middle
  6. Step 4: Map out-of-gamut colours back into sRGB
  7. The result: six ramps, one curve
  8. Step 5: Check contrast for every pairing
  9. Step 6: Name the colours and ship them as tokens
  10. How many colours should a design system have?
  11. Browser support and fallbacks
  12. The short version
  13. Frequently asked questions
  14. Further reading

The short answer

OKLCH is a way of describing colour by Lightness, Chroma (colourfulness) and Hue, designed so that equal changes in numbers look like equal changes to the eye. That makes it much better than HSL for design system palettes: if two colours share the same OKLCH lightness, they really do look equally light, and they have similar contrast against white. To build an accessible palette, pick a hue per colour family, use one shared lightness curve for every ramp, shape chroma so it peaks in the middle, map any out-of-gamut colours back into sRGB, then check contrast for every pairing you'll use.

  • OKLCH works in every major browser today: oklch(0.565 0.17 255).
  • A shared lightness curve means step 600 behaves almost the same in every hue, so contrast rules become simple.
  • OKLCH doesn't guarantee WCAG contrast. It makes contrast predictable; you still check it.

Why HSL palettes look uneven

HSL makes a promise it can't keep. Set six colours to 50% lightness and full saturation, and HSL says they're equally light. Your eyes disagree immediately: the yellow is almost white, the blue is almost navy. The numbers describe the screen's red, green and blue channels, not human perception.

HSL, all at 50% lightness

0 100% 50%L 0.634.00:1
60 100% 50%L 0.971.07:1
120 100% 50%L 0.871.37:1
180 100% 50%L 0.911.25:1
240 100% 50%L 0.458.59:1
300 100% 50%L 0.703.14:1

OKLCH, all at lightness 0.65

0.65 0.15 25L 0.653.46:1
0.65 0.15 60L 0.653.37:1
0.65 0.15 120L 0.653.14:1
0.659 0.121 178L 0.662.93:1
0.65 0.149 240L 0.653.17:1
0.65 0.15 300L 0.653.43:1
Same promise, different results. The six HSL colours all claim 50% lightness, but their perceived lightness runs from 0.45 (blue) to 0.97 (yellow), and their contrast on white runs from 1.07:1 to 8.59:1. The six OKLCH colours sit at 0.65 and their contrast stays between 2.93:1 and 3.46:1.

That's not an aesthetic quibble. It's why palettes built in HSL fail contrast checks unpredictably: "blue 600" passes 4.5:1 on white while "green 600" and "yellow 600" fail badly, even though they were built with the same numbers. Teams end up with a different rule for every hue, and nobody can remember them.

What OKLCH is, in plain terms

OKLCH is a cylindrical version of OKLab, a colour space published by Björn Ottosson in 2020 and adopted into CSS Color Level 4. It describes a colour with three numbers:

L · LIGHTNESS

0 to 1

How light the colour looks. 0 is black, 1 is white. Built to match perception, so 0.6 in red and 0.6 in green look about equally light.

C · CHROMA

0 to ~0.37

How colourful it is. 0 is grey. Unlike HSL saturation, the maximum depends on hue and lightness, because screens can't show every combination.

H · HUE

0 to 360°

Which colour: roughly 25 for red, 75 for amber, 150 for green, 255 for blue. Keeping hue fixed keeps a ramp from drifting towards purple or grey.

In CSS it looks like this, and it's supported in all current major browsers:

--blue-600: oklch(0.565 0.17 255);    /* L C H */
--blue-600-hover: oklch(from var(--blue-600) calc(l - 0.08) c h);  /* relative colour: 8% darker */

Tailwind CSS moved its default palette to OKLCH in version 4 (2025), and Evil Martians' widely read explainer helped make it the default choice for new design systems.

Step 1: Pick a hue and peak chroma for each family

Decide which colour families you need. Most product systems need a brand colour, a neutral, and feedback colours for information, success, warning and danger. For each, choose a hue angle and a peak chroma: how colourful the family is at its most vivid.

FamilyHuePeak chromaWhy
Brand (signal orange)37°0.19Taken from the brand seed colour, oklch(0.705 0.191 37)
Blue (info, links, focus)255°0.17Clear, calm, distinct from the brand hue
Green (success)150°0.17Far enough from blue to tell apart
Amber (warning)75°0.16Warm but not orange, so it doesn't clash with brand
Red (danger)25°0.21The most vivid family; errors should stand out
Neutral260°0.018A slightly cool grey; a hint of hue feels less flat than pure grey

Step 2: Use one lightness curve for every ramp

This is the step that makes the whole palette predictable. Instead of choosing lightness by eye for each colour, define eleven lightness values once, from very light to very dark, and use them for every family.

0.97550
0.945100
0.885200
0.815300
0.730400
0.645500
0.565600
0.485700
0.405800
0.330900
0.255950
The shared lightness curve: OKLCH lightness for each step, from 0.975 (step 50) to 0.255 (step 950). Every ramp uses the same curve, which is why step 600 in blue and step 600 in green have nearly the same contrast against white.

Notice the steps aren't evenly spaced. They're closer together at the light end, where small changes are easy to see and where you need subtle backgrounds, and wider in the middle, where the important text-on-white decisions happen.

Step 3: Shape chroma so it peaks in the middle

Very light and very dark colours can't hold much colour: a "vivid" near-white or near-black doesn't exist on a screen. So chroma follows an envelope: low at both ends, full in the middle. We multiply each family's peak chroma by the same envelope:

Step 50× 0.12
Step 200× 0.50
Step 400× 0.92
Steps 500–600× 1.00
Step 800× 0.78
Step 950× 0.45
The chroma envelope: a share of each family's peak chroma at each step. Light steps become tints; dark steps stay rich but not neon.

Step 4: Map out-of-gamut colours back into sRGB

Some combinations of lightness, chroma and hue can't be shown on a standard screen. OKLCH will happily describe them, so a palette generator has to bring them back inside the sRGB gamut, usually by reducing chroma until the colour fits while keeping lightness and hue as close as possible.

In practice this affects more steps than you'd expect. In our brand orange ramp, ten of eleven steps needed a small chroma reduction; step 50 asked for 0.023 and got 0.016. Blue and red mostly lost chroma only at the light end; green and amber only in the darker half. That's normal, and it's why you should generate palettes with a tool that does proper gamut mapping (we use culori) rather than typing OKLCH values and hoping. If you target wide-gamut P3 displays you can keep more chroma there, with sRGB as the fallback.

The result: six ramps, one curve

Brand (Signal)hue 37°

50#fff2ec1.1
100#ffe2d61.2
200#ffc6b11.5
300#ffa3841.9
400#ff79512.6
500#e957283.6
600#cc3c005.0
700#ab28006.9
800#861b009.7
900#63160012.8
950#430d0016.2

Bluehue 255°

50#eef8ff1.1
100#daefff1.2
200#b7dcff1.4
300#8ec6ff1.8
400#5eaaff2.4
500#3a8ef23.3
600#1c75d64.6
700#065db46.5
800#01478e9.2
900#05346812.4
950#04224615.9

Greenhue 150°

50#eefbf01.1
100#d9f6de1.1
200#b1eabc1.4
300#84d9971.7
400#51c2712.3
500#1ba9513.1
600#0090394.2
700#0076285.8
800#005b1c8.4
900#00431511.6
950#002c0c15.4

Amberhue 75°

50#fff5e91.1
100#feeacf1.2
200#f9d29e1.4
300#efb7661.8
400#dd981d2.5
500#c37c003.4
600#a467004.7
700#8652006.5
800#693e009.2
900#4f2c0012.4
950#361c0015.9

Redhue 25°

50#fff1ee1.1
100#ffe1dc1.2
200#ffc4bd1.5
300#ffa1981.9
400#ff6d682.8
500#f346473.6
600#d6242e5.1
700#b3081d7.1
800#8d01139.8
900#67080f13.0
950#46050816.3

Neutralhue 260°

50#f3f7fe1.1
100#e6edf91.2
200#d2dae51.4
300#bcc3ce1.8
400#a1a8b32.4
500#878e993.3
600#7076814.6
700#595f696.4
800#4349539.1
900#30363f12.2
950#1e232c15.8
Six ramps built in OKLCH with one lightness curve and one chroma envelope. Each swatch shows its step, hex value and contrast ratio against white. Step 700 passes 4.5:1 on white in every ramp; step 600 passes in all but green (4.16:1). Source: the Layer One design systems playbook, computed with culori.

Because every ramp shares the lightness curve, the contrast numbers line up across hues. Step 700 is between 5.8:1 and 7.1:1 on white in every family. Step 600 lands between 4.16:1 and 5.06:1, which is why we use 700 rather than 600 for text and primary actions: one rule that holds for every colour. Compare that with the HSL row above, where the same "lightness" gave anything from 1.07:1 to 8.59:1.

Step 5: Check contrast for every pairing

OKLCH makes contrast predictable, not guaranteed. WCAG 2 contrast is calculated from relative luminance, which doesn't perfectly match OKLCH lightness, so always compute it. Check the pairings you'll actually use, not every colour against white:

  • Body text on every background it appears on: at least 4.5:1 (WCAG 2.2, 1.4.3).
  • Large text (24px, or 18.66px bold): at least 3:1.
  • Input borders, icons and focus rings against their background: at least 3:1 (1.4.11).
  • Button labels on button fills, in every state including hover and pressed.
  • The same pairs again in dark mode.

A useful shortcut from a shared lightness curve: two steps far enough apart on the curve will pass, whatever their hue. In our neutral ramp, step 600 on step 50 gives 4.25:1 (fails for body text), and step 700 on step 50 gives 5.99:1 (passes). That gap rule then holds, within a small margin, for every family.

New word

APCA (the Accessible Perceptual Contrast Algorithm) is a newer contrast method that accounts for text size, weight and polarity better than WCAG 2. It's useful as a second opinion, especially in dark mode, but WCAG 2.2 is still the standard you'll be measured against.

Step 6: Name the colours and ship them as tokens

The palette is your primitive layer: blue.600, neutral.50. Products should never use it directly. Map it to semantic tokens named by job (text.link → blue.700, action.primary.bg → brand.700) and ship those to design and code. The structure and the file format are in our design tokens guide; how the same palette produces a dark theme is in dark mode with design tokens.

In practice

At CARS24 a new palette built in OKLCH replaced five different blues in the code, and became the colour of the company's rebrand across India, the UAE and Australia. Read the case study. To try the method on your own brand colour, the Lab builds OKLCH ramps from a hex value, pins your exact colour to the nearest step and checks contrast.

How many colours should a design system have?

Fewer than most teams think. A typical product needs five or six families of eleven steps (around 60 primitives) and 30–60 semantic colour tokens. If you need more, ask whether you're adding colours for decoration rather than meaning. Data visualisation is the main exception: charts need their own categorical palette, also checked for contrast and for colour-blind safety.

Browser support and fallbacks

oklch() is supported in current Chrome, Edge, Safari and Firefox. If you must support older browsers, have your token build output hex values as well (the DTCG format lets a colour carry a hex alongside its OKLCH components), and use them as a fallback:

.button { background: #ab2800; background: oklch(0.486 0.172 35); }

The short version

  • HSL lightness doesn't match perception, so HSL palettes fail contrast unpredictably.
  • OKLCH does match perception: equal lightness looks equal and behaves alike for contrast.
  • Build ramps from one shared lightness curve and a chroma envelope; gamut-map into sRGB.
  • Check contrast for real pairings in both modes. OKLCH makes it predictable, not automatic.
  • Ship the palette as primitives and expose semantic tokens to products.

Frequently asked questions

Is OKLCH supported in all browsers?

In all current major browsers, yes. For older ones, output a hex fallback from your token build.

What's the difference between OKLCH, OKLab and HSL?

OKLab and OKLCH describe the same perceptual colour space; OKLab uses a and b axes, OKLCH uses chroma and hue angle, which is easier for designing palettes. HSL is a reshuffle of RGB channels and doesn't model perception.

Does OKLCH guarantee WCAG contrast?

No. WCAG contrast uses relative luminance, which is close to but not the same as OKLCH lightness. OKLCH makes contrast consistent across hues; you still have to check it.

Can I use OKLCH in Figma?

Figma's colour picker works in hex, RGB and HSL/HSB, so most teams generate the palette in code or a plugin and import the resulting values as variables.

Should I design for P3 wide gamut?

Only if your brand needs the extra vividness. Keep sRGB values as the baseline and add P3 variants in a @media (color-gamut: p3) block.

Further reading