Colour

Relative colors

Newly availablesince Sept 2024

Replaces: A token for every variant of a brand colour. Hover, muted and border colours are derived from one source value by channel arithmetic.

See it working

The syntax

--brand:       #4f46e5;
--brand-muted: oklch(from var(--brand) l calc(c * 0.35) h);
--brand-tint:  oklch(from var(--brand) l c h / 12%);
Edit the demo’s CSS

This is the stylesheet running the demo above. Change a value and watch it. Break it on purpose: delete the modern line and you are looking at the fallback.

For browsers without it

Put a hex on the line above each derived colour. In a browser without it all four swatches above are the same indigo, which is the fallback doing its job.

Before you ship it

Feature-test the function you actually use

Support is per colour function, so MDN shows the test written against the exact form you are shipping, for example @supports (color: hsl(from white h s l)). Testing one function does not prove another. Source