If you've ever written linear-gradient(blue, yellow) and got a dull grey-ish band in the middle, the colours aren't wrong; the interpolation is. By default browsers blend gradient stops in sRGB, which isn't perceptually even. Halfway between a saturated blue and a saturated yellow in sRGB is a desaturated grey.
The fix: interpolate in OKLab or OKLCH
Modern CSS lets you choose the colour space the gradient is blended in:
/* default: blended in sRGB, muddy middle */ background : linear-gradient ( 90deg , #1e40ff , #ffd400 ) ;
/* blended in OKLab: perceptually even, no grey band */ background : linear-gradient ( in oklab 90deg , #1e40ff , #ffd400 ) ;
/* blended in OKLCH: goes "around" the hue wheel, very vivid */ background : linear-gradient ( in oklch 90deg , #1e40ff , #ffd400 ) ;
Enter fullscreen mode
Exit fullscreen mode
OKLab keeps lightness changing smoothly, so it's the safe choice for most UI gradients.
OKLCH interpolates hue as an angle, so blue→yellow passes through greens or pinks (you can…