Using color-mix() with Modern Color Spaces
You'll learn how to combine color-mix() with perceptually uniform color spaces like LCH and OKLCH for more accurate color blending.
The Core Idea
By default, color-mix() blends colors in the sRGB color space, which can produce dull or unexpected mid-tones (remember that "muddy brown" problem?). When you specify a modern color space like lch or oklch in your color-mix() function, the browser blends colors based on human perception rather than simple RGB math. This creates smoother, more vibrant gradients and variations.
How It Works
The syntax extends what you already know about color-mix():
.element {
/* Blend in OKLCH space for perceptually accurate results */
background: color-mix(in oklch, blue, yellow);
/* Control the proportions */
color: color-mix(in lch, red 70%, white);
/* Use with custom properties */
--accent: oklch(0.7 0.2 180);
--tint: color-mix(in oklch, var(--accent) 30%, white);
}
Why This Matters
Think of it like mixing paint versus mixing light. Mixing blue and yellow paint gives you green, but mixing RGB blue and yellow digitally often gives you gray. In LCH or OKLCH space, color-mix() behaves more like paint—blending through the hue wheel in a way that matches human perception. This is especially valuable for creating accessible color variants, hover states, and theming systems where consistent lightness progression matters.
Key Takeaway: Combining color-mix() with in oklch or in lch produces perceptually uniform color blends that look natural and maintain consistent brightness, avoiding the muddy results of RGB-based mixing.