opyeb ColorOKLCH

OKLCH · Display-P3 gamut · light-dark() · WCAG 2.1 · APCA

Stop picking colours. Design along lightness

Hold hue and chroma and move only lightness: eleven steps appear at once, each with its oklch() value, sRGB hex and gamut badge. Check WCAG 2.1 ratios and APCA Lc for 121 foreground and background pairs, then get a lightness correction for the pairs that fail. Copy the light-dark() tokens and Tailwind v4 @theme block, or download a .css file. Inputs never leave the browser.

Palette generator

Hold hue and chroma, move lightness
Quick hues

Eleven steps, 50–950 · press a badge to make that step the base

The formulas behind the numbers

ItemFormulaWhat this tool does
OKLCH to sRGBoklab(L, C·cos H, C·sin H) → linear RGB → gammaCSS Color 4 coefficients, 8-bit rounding
Palette stepL₅₀₀ + offset, C₅₀₀ × step factorL offset +39 to −40, C factor 0.22 to 1.0
Gamut testall three linear channels within 0–1checked for sRGB and Display-P3
Gamut clipbinary search for the largest C inside sRGB28 iterations, produces the hex approximation
WCAG 2.1 ratio(L₁ + 0.05) ÷ (L₂ + 0.05) with relative luminance4.5:1 AA · 7:1 AAA · 3:1 large text
APCA LcY = Σ(c²·⁴ × coefficient), polarity exponentsflagged below Lc 60 as body-text fail
Lightness fixC and H fixed, L moved in 0.5-point stepsthe first L that clears AA 4.5:1

The formulas are taken from CSS Color 4, WCAG 2.1 and the APCA (SAPC 0.0.98G-4g) documentation. The browser runs them, and an independent Python implementation of the same formulas is compared against all 121 pairs and 11 steps.

Thresholds

StandardBody textLarge textNote
WCAG 2.1 AA4.5:13:1the criterion where a law or contract requires WCAG 2.x
WCAG 2.1 AAA7:14.5:1worth using as the body target
APCA body minimumLc 75Lc 45minimum body band in the APCA documentation
APCA body preferredLc 90—body copy at 18px/300 and above
APCA non-body contentLc 60Lc 45text that still has to be read
APCA minimumLc 30Lc 30placeholders and disabled text

The two standards do not replace each other. WCAG 2.1 reads contrast as a brightness difference only; APCA also models polarity and spatial frequency, so the two can diverge sharply on dark backgrounds. Read both in the matrix.

Where a palette falls apart

  • Building steps in HSL — HSL lightness is a channel average, so yellow and blue at the same L have different brightness and the ramp looks uneven.
  • Keeping chroma constant — sRGB holds different chroma per hue; 0.16 sits on the edge for blue and looks washed out for yellow.
  • Judging by hex only — a P3 display shows the original oklch() colour, not the clipped hex. Read both values.
  • Eyeballing contrast — mid-tone greys and saturated middles can look fine and still fail the calculation.
  • Inverting a palette for dark mode — flipping lightness alone buries the accent. Dark mode usually needs the accent one or two steps lighter.
  • Body text on a middle step — 500 to 600 works as a button fill but rarely clears 4.5:1 as body copy.

What this tool does not do

  • Extract colours from images — no uploads; colours are entered as L, C and H.
  • Certify accessibility — these are calculations, not an audit. Use the WCAG 2.1 figures and expert review for a legal call.
  • Convert for print — CMYK and Pantone are out of scope; only screen colour spaces are calculated.
  • Approve a design system — token naming rules and review flow belong to your organisation.

Questions

How is OKLCH lightness different from HSL lightness?

HSL lightness is a plain average of the RGB channels, so two hues at the same L can look completely different in brightness: yellow at L 50% and blue at L 50% are not close. OKLCH uses the lightness axis of OKLab, which follows perception, so raising L by ten points brightens every hue by about the same amount. That is why a 50–950 ramp built on it looks evenly stepped.

What chroma should I use?

How much chroma sRGB can hold depends on hue. Yellows and greens take 0.2 and more, while blues and violets leave sRGB around 0.15. The calculator binary-searches the largest chroma inside sRGB for every step, uses that for the hex value, and badges whether the requested chroma was clipped. UI palettes usually sit between 0.02 (neutral) and 0.18 (accent).

What happens to colours outside sRGB?

The oklch() function accepts out-of-gamut values and the browser maps them to the display gamut, but browsers that do not know oklch() and tools that only accept 8-bit hex need a fallback. So for every out-of-gamut step the generator writes (1) a chroma-reduced sRGB hex and (2) an `@supports (color: oklch(0 0 0))` block that restores the original oklch() value. On a Display-P3 screen the original chroma survives.

Should I judge with WCAG 2.1 or APCA?

If a law or contract requires WCAG 2.x, the WCAG 2.1 figures are the criterion. APCA is a candidate method for the WCAG 3 draft and is not yet a conformance test, but it models dark backgrounds better than WCAG, which overstates contrast there. In practice, hold 4.5:1 as the floor and check APCA Lc 60–75 as the body-text target.

How far does light-dark() reach?

Chrome and Edge 123 (March 2024), Safari 17.5 (May 2024) and Firefox 120 (November 2023). It reached Baseline in May 2024 and covered about 91.6% of global users in November 2026. It needs `color-scheme: light dark`, and the export includes a prefers-color-scheme fallback for browsers without it.

Where do my colours go?

Nowhere. The L, C and H maths, gamut checks, contrast calculations, code generation and file downloads all finish in the browser; nothing is sent to or stored on a server. A share link keeps values after the # in the address and that part is never transmitted. Only the theme choice is stored locally.

How do I fix a pair that fails contrast?

Pick a cell in the matrix to see its WCAG ratio and APCA Lc. The L-correction button keeps chroma and hue and moves lightness in 0.5-point steps until the first L that clears 4.5:1 (or 7:1). Applying it moves the sliders, and the full table lists the corrected L for every failing step against the light and dark backgrounds.

Basis and sources

W3C — CSS Color Module Level 4 (oklch(), color(), gamut mapping)

The specification that defines oklch(), the L 0–1 and 0–100% forms, the sRGB and Display-P3 colour spaces and how out-of-gamut colours are handled. The calculator uses these transforms.

W3C — CSS Color Module Level 5 (light-dark(), color-mix(), relative colour syntax)

Defines light-dark(), color-mix(), relative colour syntax and how they interact with color-scheme. The basis for the exported CSS.

W3C — Web Content Accessibility Guidelines 2.1, 1.4.3 and 1.4.11

The 4.5:1 body-text, 3:1 large-text and 7:1 AAA thresholds and the relative-luminance formula behind the AA and AAA badges in the contrast matrix.

APCA — Accessible Perceptual Contrast Algorithm (APCA in a Nutshell)

The WCAG 3 candidate contrast method: how Lc is computed and what the levels mean (90 preferred body text, 75 minimum body text, 60 non-body content, 45 large text, 30 any text, 15 non-text).

Björn Ottosson — A perceptual colour space for gamut mapping (OKLab)

The original OKLab paper: the transform matrices between sRGB and OKLab and why its lightness is perceptually even. Source of the coefficients used here.

MDN — light-dark() and color-scheme

How light-dark() works, why color-scheme: light dark is required, and the browser support (Baseline since May 2024).

Tailwind CSS v4 — Theme variables (@theme)

Defining a palette with --color-* variables inside @theme. The basis for the exported Tailwind v4 block.

Chrome for Developers — OKLCH in CSS: why we moved from RGB and HSL

Why HSL lightness does not match perception and what improves when a palette moves to OKLCH (even lightness steps, predictable hue), with worked examples.

ColorOKLCH is a colour calculator, not an accessibility certification. Every value is computed in your browser from the L, C and H you enter and the published specifications (WCAG 2.1, CSS Color 4 and 5, APCA). Contrast figures change with the display, font, weight and user settings, and APCA is still a candidate method for the WCAG 3 draft. Where a law or contract requires WCAG 2.x, judge with the WCAG 2.1 figures, and test important screens with real users.

The site outline and definitions are in llms.txt, and input handling and cookies in the privacy policy. Bug reports and questions go through the OPYEB contact form.

Step 500—
Palette