Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
Reference / CSS

color-mix()

Takes two color values and returns the result of mixing them in a given color space by a specified amount.

Syntax
color-mix(in <color-space>, <color> [<percentage>], <color> [<percentage>])

Parameters

NameTypeDescription
color-spacesrgb | oklch | hslInterpolation color space.
color1, color2colorColors to blend.

Examples

Creating subtle tinted backgrounds dynamically
:root {
    --primary: #f05638;
    --tinted-bg: color-mix(in srgb, var(--primary) 12%, transparent);
    --hover-btn: color-mix(in oklch, var(--primary) 85%, black);
}
Eliminates the need for preprocessors (Sass) to calculate tint and shade variations.