Skip to main content
Dublin Library

The Publishing Project

Color Interpolation and Hue Interpolation

 

While I was researching gradients, I came across a couple of interesting features introduced in the CSS Color Level 4 specification

You can specify the color you want the gradient to run on. This is called hue interpolation.

The example below uses the OKLab color space in the conic gradient

.oklab01 {
  background: conic-gradient(
    in oklab,
    red,
    orange,
    yellow,
    green,
    blue,
    indigo,
    violet
  );
}

You can also specify how browsers interpolates the hues in a gradient

The four possible values are:

  • shortest
  • longest
  • increasing
  • decreasing

The Codepen below shows the different hue interpolation methods used with the same two colors from cyan to blue.

Edit on Github