2.3 · Color
Blend in any color space: color-mix()
Blend two colors in the browser, in the color space you choose.
color-mix(in oklch, var(--a), var(--b) 30%) blends two
colors. The first argument is the color space the browser mixes in,
and it changes the result a lot. Mixing blue and yellow in
srgb passes through a muddy gray. In
oklch it travels around the hue wheel and stays vivid.
Mixing with white, black or
transparent is a quick way to make tints, shades and
translucent versions.
// Sass, at build time only
$tint: mix($brand, white, 20%);
/* Live, and it works with variables */
--tint: color-mix(in oklch, var(--brand) 20%, white);
--glass: color-mix(in srgb, var(--brand), transparent 70%);