CSS color-mix() Generator
Generate CSS color-mix() declarations by picking two colors, a color space, and a blend percentage. The live swatch approximates the mix (exact mix depends on the browser's implementation of the chosen space), and the output is ready to paste into your stylesheet. Mixing in oklch or oklab avoids the muddy grays you get with sRGB midpoints.
How to use the CSS color-mix() Generator
1. Pick Color 1 and Color 2 using the swatches or typing hex values. 2. Choose the color space — oklch is recommended for perceptually uniform mixes that stay vivid through the midpoint. 3. Drag the percentage slider to set how much of Color 1 is in the mix (e.g., 60% means 60% Color 1 + 40% Color 2). 4. The output textarea shows the ready-to-copy color-mix() CSS value. The on-screen swatch is a JS-computed approximation; the browser renders the real mix at runtime.
What is CSS color-mix() and why does color space matter?
color-mix(in colorspace, color1 pct%, color2) is a native CSS function (Baseline 2023, supported in all major browsers) that blends two colors in a given color space. The result is the interpolated point at pct% along the line between the two colors in that space. Because different spaces have different geometries, the same two colors mixed at 50% can produce visibly different midpoints.
Mixing in sRGB — the traditional approach — causes notorious muddy browns and grays near the midpoint of vivid hue pairs (mix blue and orange in sRGB and the middle is a dull brown). Mixing in oklab or oklch keeps the midpoint perceptually bright, because those spaces are designed so that equal distances correspond to equal perceived differences. oklch is particularly useful because it exposes hue as an angle — you can see the hue arc the mix traverses.
The percentage applies to the first color; the remainder goes to the second. You can omit the percentage for the second color — the browser infers it. color-mix() is especially useful for generating tints and shades of design tokens, creating hover/active state variants, and building accessible focus rings without maintaining a separate palette.
Common use cases
- Design token tints — mix a brand color with white or black in oklch to generate accessible light/dark variants without a preprocessor.
- Hover state generation —
color-mix(in oklch, var(--btn-bg) 80%, black)darkens a button on hover using only CSS, no Sass darken(). - Palette midpoints — create a visually pleasing midpoint between two palette colors for a gradient or a stepped scale in oklch space.
- Theme adaptation — mix a static brand color with
currentColoror a CSS variable for automatic light/dark mode blending. - Transparent overlays — mix a solid color with
transparentto achieve a native CSS opacity fade without changing the alpha channel globally.