CSS color-mix() Generator

Mix any two colors with the modern CSS color-mix() function. Pick an interpolation space (oklch, srgb, lab, hsl), drag the ratio slider, and copy a production-ready snippet.

About This Tool

Modern CSS gives you a single function — color-mix() — that replaces a pile of Sass helpers, opacity hacks, and #hex math gymnastics. This generator wraps that function in a visual editor so you can pick the two inputs, choose the interpolation color space, drag the ratio, and copy a snippet that drops directly into a stylesheet, design token file, or Tailwind arbitrary value.

The headline feature is interpolation in any color space. Mixing red and blue in srgb produces the muddy purple every web designer learned to avoid; mixing the same two colors in oklch walks through a clean, perceptually uniform gradient because OKLCH separates lightness from chroma and hue. The comparison panel below the preview renders the same two colors interpolated in six different spaces side-by-side so you can see — not just read about — why "in oklch" became the default recommendation in modern design systems. If you have not yet adopted OKLCH for your tokens, our color converter helps translate existing HEX/RGB palettes into the new format.

color-mix() also pairs naturally with the rest of the modern CSS color toolkit. Combine it with currentColor to derive surface and border tints from a single brand variable, with custom properties to build dark-mode shade scales, or with the new Relative Color Syntax (oklch(from var(--brand) calc(l + 0.1) c h)) to perform per-channel math. When you finalize a palette, run the foreground/background pairs through our accessibility color checker to confirm WCAG AA/AAA contrast, and use the gradient generator when you need more than two stops.

Everything runs locally. The browser's own style engine resolves every mix via getComputedStyle, so the preview is exactly what your users will see — no server round trips, no telemetry on the colors you paste, and no third-party color library shipped in the bundle. Browser support landed in Chrome/Edge 111, Safari 16.2, and Firefox 113, which together cover well over 95% of global traffic; the generator detects missing support and shows a fallback notice when needed.

How to Use

  1. Pick Color 1 and Color 2 with the swatch picker or by typing a HEX value (#rrggbb or #rgb) and pressing Enter.
  2. Choose an Interpolation color space from the dropdown — oklch is the modern default; switch to srgb for the legacy look.
  3. Drag the Mix ratio slider to control how much of each color contributes (0%–100%).
  4. Watch the Live preview swatch update instantly. The resolved sRGB hex appears below for quick reference.
  5. Scroll to Same mix across color spaces to compare how the result differs in srgb / srgb-linear / hsl / oklch / oklab / lab.
  6. Click Swap to flip the two colors (the ratio inverts automatically) or Reset to return to the red/blue defaults.
  7. Click Copy CSS or press Ctrl+Shift+C to copy the generated color-mix(...) expression to your clipboard.

Popular color-mix() Examples

View all 15 color-mix() examples →

FAQ

What is CSS color-mix()?

color-mix() is a CSS Color Module Level 5 function that interpolates between two colors in a chosen color space. The syntax is color-mix(in <colorspace>, <color1> <percent>, <color2> <percent>). It removes the need for Sass mixins, custom property math, or runtime JavaScript when you want tints, shades, hovers, or theme variants derived from a base color.

Why use OKLCH instead of sRGB for color mixing?

Mixing two colors in sRGB is mathematically simple but perceptually wrong: the midpoint between two saturated colors loses chroma and looks muddy or grey. OKLCH (and OKLab) is a perceptually uniform space derived from human vision research. When you mix red and blue in oklch, the path stays bright and saturated, producing a clean purple. This is why design systems like Tailwind v4, Radix Themes, and Material You moved to OKLCH-based palettes.

Which browsers support color-mix()?

color-mix() is supported in Chrome 111+, Edge 111+, Safari 16.2+, Firefox 113+, and all major mobile browsers from the same vintage. Combined that is roughly 95%+ of global traffic as of 2025. For older browsers, ship a static fallback color first and let modern browsers override it: 'background: #7f007f; background: color-mix(in oklch, red, blue);'.

What is 'longer hue' vs 'shorter hue'?

When interpolating in a polar color space (hsl, hwb, lch, oklch), there are two ways around the hue wheel: the short arc and the long arc. The default is 'shorter hue'. Adding 'longer hue' forces the interpolation to take the long way around, which is useful for rainbow-style transitions. Example: color-mix(in hsl longer hue, red 50%, blue 50%) sweeps through yellow, green, and cyan instead of going through magenta.

When should I use Lab vs OKLCH?

Both are perceptual spaces, but OKLCH/OKLab were specifically tuned in 2020 by Björn Ottosson to fix issues that the older CIE Lab/LCH spaces had with blue and purple hues. For UI work and design tokens in 2025, prefer OKLCH unless you have a hard requirement to interoperate with legacy print or imaging pipelines that already speak CIE Lab. The difference is most visible around blue: a mix in lab can take an unexpected turn through purple, while oklch stays in the expected hue family.

Does color-mix() handle alpha and currentColor?

Yes. Each input color carries its own alpha and the result's alpha is interpolated alongside the color channels. You can also pass currentColor as an input — for example, color-mix(in oklch, currentColor 80%, transparent) gives you a faded version of whatever color the element currently inherits. This is the modern, accessible replacement for opacity hacks that affected child elements.

Is my data safe?

Yes. The generator is a single client-side React component. Color values you type are kept in component state, the CSS expression is built with plain JavaScript string templates, and previews are rendered by passing the expression to the browser's own style engine via getComputedStyle. There is no network call, no analytics on the colors you paste, and no third-party color library. You can confirm by opening DevTools Network tab while you experiment.

Related Tools