CSS color-mix() generator — write and preview color-mix() with a fallback

Pick two colours, the share of the first, an interpolation space and a hue method, and get the exact color-mix() line, the colour browsers will compute, and a HEX fallback.

Live demo · real result from this tool

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use the CSS color-mix() generator

  1. Pick the First colour and set First colour amount (0–100%). The second colour gets the remainder.
  2. Pick the Second colour.
  3. Choose the Interpolation space: sRGB, Linear sRGB, OKLab, OKLCH, CIE Lab, CIE LCH, HSL or HWB.
  4. For OKLCH, LCH, HSL or HWB, choose the Hue interpolation: Shorter arc, Longer arc, Increasing or Decreasing.
  5. Read the Computed colour and copy the CSS block, which has a HEX fallback followed by the color-mix() line.

What it does and when to use it

color-mix() lets CSS blend two colours at render time, so a hover colour, a border tint or a translucent surface can follow a theme variable automatically. Writing it is easy; predicting the result is not, because the space and hue method change the outcome a lot. This generator shows you the computed colour first, then gives you code in exactly the syntax the CSS Color Level 5 specification uses.

Use it when replacing Sass mix() with native CSS, when building theme tokens such as color-mix(in oklab, var(--brand) 80%, white), or when debugging an unexpected colour. For a quick two-colour blend with quarter steps, the colour mixer is simpler. For many stops in a row, use the gradient generator, and the CSS colour names reference lists keywords you can mix.

How it works

The tool follows the CSS color-mix() rules. With first amount p, the second amount is 100 − p. Both colours are converted to the chosen space and interpolated at p2 ÷ 100 of the way from the first to the second, with premultiplied alpha. In polar spaces the hue follows the chosen hue method, and a grey end takes the other colour’s hue. The result is converted back to sRGB and gamut-mapped for the HEX fallback.

Worked examples

These are the generator’s own outputs for red #ff0000 at 50% with blue #0000ff.

Space and hue Computed
srgb #800080
oklch, shorter #b700be
oklch, longer #008a0e

The sRGB line it writes is background: color-mix(in srgb, #ff0000 50%, #0000ff);, with background: #800080; above it as the fallback. In oklch with the longer arc the hue swings through green, and the code becomes color-mix(in oklch longer hue, #ff0000 50%, #0000ff).

Limits and tips

  • Only the first percentage is set here, so the two amounts always add up to 100%. CSS also allows amounts that add up to less, which makes the result partly transparent.
  • The fallback is a fixed colour; it will not follow a CSS variable.
  • Everything is computed in your browser.

Frequently asked questions

What does the percentage in color-mix() mean?
It is the share of that colour in the mix. color-mix(in srgb,
Which interpolation space should I use?
srgb matches older tools and Sass. oklab gives smooth, even-looking blends and is a good default for tints and shades. oklch keeps colours vivid between different hues. srgb-linear behaves like mixing real light.
What do shorter and longer hue do?
In polar spaces (oklch, lch, hsl, hwb) the hue can travel either way round the colour wheel. Shorter takes the short arc, the default. Longer goes the long way round, so red and blue in oklch meet at green
Why add a HEX fallback?
Browsers that do not understand color-mix() ignore the whole declaration. With the HEX line first, they use that colour, and modern browsers override it with the color-mix() line.
Why does the OKLCH value differ slightly from the HEX?
The OKLCH line shows the mix before gamut mapping. If the mix is more vivid than sRGB allows, the HEX is the nearest displayable colour, which is what a standard screen shows.

Sources

  1. CSS Color Module Level 5 — color-mix() — W3C, accessed 2026-10-08
  2. CSS Color Module Level 4 — hue interpolation and gamut mapping — W3C, accessed 2026-10-08

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close