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
| Name | Type | Description |
|---|---|---|
| color-space | srgb | oklch | hsl | Interpolation color space. |
| color1, color2 | color | Colors 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.