| name | oklch-colors |
| description | OKLCH color space reference for CSS. Use when: choosing colors, building palettes, converting hex/rgb/hsl to oklch, checking perceived lightness, creating accessible color scales, working with P3 or wide-gamut colors. |
OKLCH captures perceived Lightness, Chroma, Hue, and Alpha. Values are human-readable and differences are predictable just by reading them. It represents wide-gamut colors (P3, Rec2020) that HSL and RGB cannot.
OKLCH improves on LCH by fixing a bug in the blue chroma range and providing better gamut correction.
Syntax
.c { color: oklch(0.8 0.12 100 / 100%); }
- Lightness
0–1: Perceived brightness. 0 = black, 1 = white. Equal steps look equal.
- Chroma
0–0.4: Color intensity. 0 = gray, higher = more vivid. Most usable colors sit between 0.05–0.2.
- Hue
0–360: Color wheel angle. 0 = pink/red, 90 = yellow, 150 = green, 225 = blue, 300 = purple.
- Alpha
0%–100%: Opacity. Optional, defaults to 100%.
Quick Reference
.bw {
color: oklch(0 0 0);
color: oklch(1 0 0);
color: oklch(0.5 0 0);
}
.colors {
color: oklch(0.8 0.12 100);
color: oklch(0.6 0.12 100);
color: oklch(0.8 0.05 100);
color: oklch(0.8 0.12 225);
}
.opacity {
color: oklch(0.8 0.12 100 / 50%);
}
Key Advantages
- Perceptually uniform: Equal lightness steps look equal. Two colors at
L=0.7 appear equally bright regardless of hue — not true in HSL.
- Predictable manipulation: Darken by subtracting from L, desaturate by reducing C, shift hue by changing H. Each axis is independent.
- Wide gamut: Represents P3 and Rec2020 colors that sRGB hex/rgb cannot.
- Better than LCH: Fixes the blue hue shift bug present in CIE LCH.
Building Accessible Scales
To create a color scale with guaranteed contrast:
--violet-100: oklch(0.95 0.03 250);
--violet-300: oklch(0.80 0.08 250);
--violet-500: oklch(0.65 0.15 250);
--violet-700: oklch(0.45 0.15 250);
--violet-900: oklch(0.25 0.10 250);
Each 0.15 lightness step gives roughly 3:1 contrast between adjacent levels.
Common Patterns
Tinted neutrals — warm or cool grays with a subtle hue:
--neutral-warm: oklch(0.95 0.01 60);
--neutral-cool: oklch(0.95 0.01 250);
Semantic colors — consistent lightness for equal visual weight:
--success: oklch(0.72 0.17 145);
--warning: oklch(0.80 0.16 75);
--error: oklch(0.65 0.20 25);
--info: oklch(0.70 0.12 240);
Dark mode counterparts — same hue/chroma, higher lightness:
--accent: oklch(0.55 0.20 285);
--accent: oklch(0.75 0.15 285);
Tooling