Skip to main content
Colors · 287 tools

CSS color-mix() Calculator

Mix two colors in OKLCH, Lab, or sRGB at any ratio and copy the exact CSS color-mix() syntax — with a live hex preview of the result.

Added October 2026

About this generator

CSS color-mix() shipped in every evergreen browser by mid-2023 and quietly turned into one of the most useful stylesheet features of the decade. The entire argument for a modular design system — tints, shades, hover states, disabled states, low-emphasis variants — collapses from "generate a dozen hex tokens per color" to "mix the base color with white, black, or a neutral at a few percentages." The problem is that the choice of color space inside the function changes the answer in ways that are not obvious until you see them. Mixing #2563EB with #F59E0B at 50% in sRGB gives you a muddy taupe that reads as "neither color." The same mix in OKLCH gives you a saturated, hue-aware midpoint that keeps the perceived vibrancy of both ends intact. The same mix in Lab lands somewhere in between, usually a little cleaner than sRGB but not as crisp as OKLCH. This calculator is a playground for that choice. Pick two colors, pick a mixing percentage, pick a space, and you see the resulting hex plus the exact CSS color-mix() syntax you can paste into a stylesheet. The hex preview is computed with the real color-space math — sRGB linear interpolation for in srgb, OKLab-channel interpolation for in oklch and in oklab, and CIE Lab-channel interpolation for in lab — so what the swatch shows is what the browser will render. The headline recommendation, well understood by now in the design-tool community, is "in oklch, every time, unless you have a specific reason." OKLCH interpolation produces mid-colors that match perceptual expectation, keeps lightness changes even across hues, and avoids the dead-grey midpoint that bedevils sRGB. The exception is when you are mixing a color with a near-white or near-black tint and want to preserve the exact HSL-style lightness ramp a designer baked into Figma — in that case Lab interpolation sometimes reads cleaner, and sRGB is defensible for backwards compatibility with hand-crafted palettes from the pre-OKLCH era. The percent input is the weight of color A — 50% is a true midpoint, 25% leans toward B, 75% leans toward A. Internally the calculator normalises the two weights to sum to 100% exactly as the CSS spec requires, so the preview and the exported CSS always agree. The output is designed for drop-in use: the hex is the fallback value for browsers you no longer need to support, and the color-mix() string is the forward value that browsers do support. In practice, most teams ship both as a `color: color-mix(...)` with a `color: <hex>` fallback above it, and let the cascade sort it out. If you are building a semantic color scale from a single brand color, this calculator plus the OKLCH Color Converter is roughly 80% of the pipeline — generate ten mixes with white at 5% through 50%, generate ten mixes with black at 5% through 50%, and you have a complete tint-and-shade scale that is perceptually even in a way manual Figma-eyeball picks almost never are.

Use Cases

  • •Generate a semantic tint/shade scale from a brand color by mixing with white and black in OKLCH.
  • •Preview a hover state as 90% base + 10% black before committing it to the CSS token layer.
  • •Compare the same mix across OKLCH, Lab, and sRGB to decide which interpolation space the design system should standardise on.
  • •Produce the exact CSS color-mix() string for a disabled state so engineering can paste it without rounding.
  • •Explore gradient midpoints visually by sweeping the percentage slider between two palette colors.
  • •Teach a design-system working group why "mix two colors" is not a space-free operation.

FAQ

Which browsers support color-mix() natively?

All evergreen browsers as of 2024 — Chrome 111+, Safari 16.2+, Firefox 113+. Older browsers need the hex fallback the calculator provides.

Why does mixing in sRGB look muddy?

Linear interpolation in sRGB walks through the geometric midpoint of the two color vectors, which, for complementary pairs, passes through grey. Perceptually uniform spaces like OKLab route the path through colors that match human perception of a midpoint instead.

What is the difference between oklch and oklab in color-mix()?

Negligible for a straight midpoint between two colors — the components are the same, just expressed in rectangular (a,b) versus polar (C,h) form. The difference matters when you specify a hue-interpolation method such as `hue longer` or `hue shorter`, which only applies in cylindrical spaces (hsl, hwb, lch, oklch) and does nothing in rectangular ones (lab, oklab, srgb).

How accurate is the hex preview?

It matches modern browser rendering to within one unit per channel for all three spaces. If you see a mismatch between the preview and a browser render, check that the browser is using the OKLab-based implementation, not an older polyfill.

Can I mix more than two colors?

The CSS spec supports exactly two colors per color-mix() call. For a three-way or four-way mix, chain two calls — mix A and B first, then mix the result with C — and remember that the second mix uses the perceptual midpoint of A and B, not the raw inputs.

You might also like

Popular tools from other categories that share themes with this one.