CSS color-mix() Function (No Sass Required)
Mixing colors without a preprocessor
Blending two colors used to require Sass, Less, or a JS utility. color-mix() does it in plain CSS, and it supports perceptually uniform color spaces like oklch.
The old hack vs the modern fix
View demo// _variables.scss
$blue: #3b82f6;
$pink: #ec4899;
$blend: mix($blue, $pink, 60%);.card {
background: color-mix(in oklch, #3b82f6 60%, #ec4899);
}<!-- Tailwind v4 — color-mix via arbitrary value --><div class="bg-[color-mix(in_oklch,#3b82f6_60%,#ec4899)]">Mixed</div><!-- v4 opacity modifiers use color-mix natively --><div class="bg-blue-500/50">50% blue</div>Color mix browser support
Live demo
Why the modern way wins
Perceptually uniform
Mix in oklch for results that look natural to the human eye, unlike Sass's sRGB mixing.
Dynamic at runtime
Change the mix with custom properties, no recompilation. Works with themes, dark mode, anything.
No build step
Drop Sass, PostCSS, or any preprocessor for color manipulation. Native CSS does it now.
- Dependency Removed
- Sass
- No more mix() import
- Old Approach
- Build-time
- Static, compiled output
- Modern Approach
- Runtime
- Dynamic, themeable
How it works
color-mix(in oklch, color1 percentage, color2) blends two colors in the specified color space. The percentage controls how much of the first color to use.
The oklch color space is perceptually uniform, meaning a 50/50 mix of blue and yellow actually looks like a midpoint, unlike sRGB mixing which often produces muddy results. You can also use srgb, hsl, lab, or lch.
The best part: combine it with custom properties for dynamic theming. color-mix(in oklch, var(--brand) 80%, white) gives you a lighter variant of any brand color, at runtime, no build step.