Mixer

Color mixer

Blend two colours at any ratio, and see why the same mix looks different in sRGB and OKLab.

Colour A

#0000ff

Mix · 50%

sRGB#808080
OKLab#6cabc7
A50%
B50%

Colour B

#ffff00

The same ramp in both spaces

midpoint saturation: sRGB 0% · OKLab 45%

sRGB

  • #0000ff
  • #2020df
  • #4040bf
  • #60609f
  • #808080
  • #9f9f60
  • #bfbf40
  • #dfdf20
  • #ffff00

OKLab

  • #0000ff
  • #0053f4
  • #1d77e7
  • #4693d8
  • #6cabc7
  • #90c2b2
  • #b5d797
  • #daec6f
  • #ffff00
color-mix(in oklab, #0000ff 50%, #ffff00)

Mixed colour

  • HEX#6cabc7
  • RGBrgb(108, 171, 199)
  • RGBArgba(108, 171, 199, 1)
  • HSLhsl(198, 45%, 60%)
  • HSLAhsla(198, 45%, 60%, 1)
  • HSVhsv(198, 46%, 78%)
  • CMYKcmyk(46%, 14%, 0%, 22%)approx
  • LABlab(66.85 -12.75 -20.59)approx
  • CSSrgb(108 171 199)

Closest CSS keyword: skyblue approximate: #87ceeb is 12.55 ΔE away, so it is not the same colour

oklchoklch(70.9% 0.077 228.0)

01

Why the middle goes grey

Take blue #0000ff and yellow #ffff00. Average them channel by channel and you get #808080, a mid grey. That is arithmetically correct and perceptually absurd: nobody would say grey sits between blue and yellow.

It happens because the red and green channels rise from 0 to 255 while blue falls from 255 to 0. Halfway along, all three are at 128, and equal channels mean a neutral. The blend passed through the grey axis of the colour space.

OKLab does not have this problem because it does not store colour as three light levels. It stores lightness on one axis and two opponent axes for colour. Moving between two colourful points does not route through the neutral centre unless the colours really are opposites.

02

Which space to use

Use OKLab when a person is going to look at the result: gradients, colour ramps for a design system, hover and pressed states, chart scales, anything where the intermediate values matter.

Use sRGB when you need to match something that already interpolates in sRGB, such as a CSS gradient without an in keyword, a canvas composite, or an existing design token set someone else generated.

Neither is more correct in the abstract. sRGB interpolation is what browsers have always done, so it is what most existing work looks like. OKLab is what you would choose if starting today.

03

Doing it in CSS

CSS can do this natively now. color-mix() blends two colours in a space you name, and gradients accept the same in keyword:

color-mix(in oklab, #0000ff 50%, #ffff00)
linear-gradient(in oklab, #0000ff, #ffff00)

Both are supported across current browsers. If you need to support older ones, generate the intermediate stops here and write them out explicitly. An explicit multi-stop gradient in sRGB reproduces an OKLab gradient closely enough that nobody will spot the difference.

For building a full ramp around a single colour rather than between two, the colour picker generates tints and shades, and the palette generator covers harmonies.

Frequently asked questions

Why do the two ramps look different?

Because sRGB numbers are not proportional to perceived colour. Averaging the channels of blue and yellow gives a desaturated grey, since the red and green channels meet in the middle while blue drops away. OKLab is built so that equal numeric steps look like equal perceptual steps, so its midpoint keeps the chroma you would expect.

Which one should I use?

OKLab for anything a person will look at, such as gradients, colour ramps, hover states and chart scales. sRGB when you need to match what another system already does, because CSS gradients and canvas compositing still interpolate in sRGB by default.

How do I get OKLab interpolation in CSS?

Modern CSS supports it directly: `linear-gradient(in oklab, blue, yellow)` for gradients and `color-mix(in oklab, blue, yellow)` for a single blend. Both are widely supported now. Where you need a fallback, generate the steps here and emit explicit stops.

Is this the same as mixing paint?

No. Paint is subtractive: pigments absorb light, so blue and yellow give green. Both spaces here are additive, describing emitted light, where blue and yellow give a neutral. Neither model predicts what happens on a palette knife.

Read the guide

  • sRGB, Display P3 and OKLCHWhy the same hex looks different on two screens, what a wide gamut buys you, and when the newer CSS colour spaces are worth the trouble.
  • How to use color codes in CSSEvery way CSS accepts a colour, why custom properties beat repeating hex codes, and the relative-colour syntax that replaces most of your Sass functions.