Relative colour syntax — deriving one colour from another
Relative colour syntax derives a new colour from an existing one. oklch(from var(--brand) calc(l + 0.1) c h) keeps chroma and hue and raises lightness by 0.1. It shipped in Safari in 2023, Chrome later that year and Firefox in 2024, and by 2026 it is dependable in current browsers.
The syntax
.btn { background: oklch(58% 0.16 250); }
.btn:hover { background: oklch(from currentColor calc(l + 0.08) c h); }
.border { border-color: oklch(from var(--brand) l calc(c × 0.4) h); }
.disabled { background: oklch(from var(--brand) l c h / 0.5); }
After from comes the source colour, then the new channel values. The channels are available as l, c, h and alpha, and calc() can combine them. Writing a channel variable alone keeps that channel unchanged.
Why it helps
It removes derived tokens. Hover, pressed, disabled, border and shadow colours can all be computed from one source, so a growing palette cannot drift. Change the theme colour and the derived colours follow. In a design system this removes a large class of hand-maintained variants.
What to watch
- The result can leave the gamut. Browsers map it, but the contrast may not be what you planned.
- Do not mix channel units inside calc(): L is 0–1 or a percentage, C is 0–0.4.
- Relative colour can use the inherited currentColor, which is convenient but means a parent change moves the result.
- Older browsers drop the whole declaration, so declare a fallback colour first.
Contrast is the real risk. A hover colour derived by raising lightness may fall below 4.5:1 against its background. Check derived colours in the contrast matrix. Text colour in particular is better given an explicit step value than computed.
Using it with this tool
Build the palette here, then use one step as the source for derived decorative tokens. Finish contrast corrections first with the L-correction tool, and keep derived colours for decoration and states that do not carry text. Discrete, tested steps for text remain the predictable choice.
| Use | Example | Note |
|---|---|---|
| Hover | oklch(from var(--brand) calc(l + 0.06) c h) | recheck contrast |
| Pressed | oklch(from var(--brand) calc(l - 0.06) c h) | reverse on dark themes |
| Border | oklch(from var(--brand) l calc(c × 0.3) h) | no contrast rule if decorative |
| Disabled | oklch(from var(--brand) l c h / 0.45) | never for text |
Relative colour syntax is defined in CSS Color Module Level 5.
Questions
Where is relative colour syntax supported?
Chrome 119, Safari 16.4 and Firefox 128 onwards. In 2026 current browsers support it, but declare a fallback colour for older ones.
Can I use currentColor as the source?
Yes. oklch(from currentColor ...) derives from the inherited text colour, which is handy for icons inside buttons.
Does a derived colour keep its contrast?
No. CSS cannot know the resulting value, so important text should use an explicit step.
Pick a base colour in the palette, then derive from it in CSS.
Open the toolBasis date 28 November 2026. Written against the W3C specifications, the APCA documentation and published browser support tables; updated when they change.
Back to the guides