Sub topic 9
Hue interpolation: shorter, longer, increasing, decreasing
This chapter assumes you know color-mix() syntax, the three oklch() components, and how to pick an interpolation color space. Here you will learn how to control which way the hue travels when you mix or blend two colors.
Why hue needs a rule
Lightness and chroma are plain numbers on a line. Hue is an angle on a circle, from 0 to 360 degrees. To get from one hue to another you can go clockwise or counterclockwise, and the two routes can pass through very different colors.
In OKLCH, red sits near hue 29 and blue near hue 264. The gap is 235 degrees one way and 125 degrees the other. The route you pick decides whether the mix passes through purple and magenta or through yellow, green and cyan.
The default: shorter hue
If you do not name a method, CSS uses shorter hue. It takes the smaller arc, which is never more than 180 degrees. You can also write it out:
.swatch-a {
background: color-mix(in oklch, red, blue);
}
.swatch-b {
background: color-mix(in oklch longer hue, red, blue);
}.swatch-a goes from red down through hue 0 to 264, so a 50% mix lands on a magenta-purple near hue 326. .swatch-b goes the long way, up through yellow, green and cyan, so a 50% mix lands on a green near hue 146.
The four methods
| Method | Direction | Path length |
|---|---|---|
| `shorter hue` | Whichever way is shorter | Up to 180 degrees |
| `longer hue` | Whichever way is longer | At least 180 degrees |
| `increasing hue` | Always upward in angle | 0 to 360 degrees |
| `decreasing hue` | Always downward in angle | 0 to 360 degrees |
shorter and longer choose a route by length, so you do not need to know which direction it runs. increasing and decreasing fix the direction instead. Use them when you need a particular route regardless of where the two hues sit. For example, increasing hue from 29 to 264 gives the same route as longer hue here. Between 264 and 29, increasing hue would cross 360 and take the 125-degree arc, which is the shorter one.
Using it in gradients
The same keywords work in gradients. The syntax is in <space> <method> hue:
.rainbow {
background: linear-gradient(in oklch longer hue, red, blue);
}
.sunset {
background: linear-gradient(in oklch shorter hue, orange, purple);
}longer hue is a quick way to get a rainbow-like band from two endpoints. Because lightness and chroma are interpolated too, the band keeps steadier brightness than the same gradient in HSL.
Where hue methods apply
Only polar color spaces have a hue channel: oklch, lch, hsl and hwb. Rectangular spaces such as oklab, srgb and lab have no hue to route around, so adding a hue method there is invalid. The browser drops the whole declaration.
.invalid {
/* Invalid: oklab has no hue channel. */
background: color-mix(in oklab longer hue, red, blue);
}Grays have no hue
White, black and pure grays have zero chroma, so their hue is meaningless. CSS treats it as missing and borrows the hue from the other color instead of interpolating toward an arbitrary angle:
.tint {
background: color-mix(in oklch, white, var(--brand) 20%);
}The result keeps the hue of --brand and no hue method is needed. This is one reason mixing with white or black in OKLCH gives clean tints and shades. Mixing in a space where gray has a defined hue can drag the result toward an unwanted color.
Choosing a method
- Use the default
shorter huefor tints, shades, hover states and most palette work. It keeps the result close to both inputs. - Use
longer huefor decorative gradients where you want to pass through many colors. - Use
increasingordecreasingwhen the direction matters, such as a theme that must always move from warm hues toward cool ones. - Watch out for hues about 180 degrees apart. A tiny change in either input can flip which arc counts as shorter, so the mix jumps to a very different color. If this affects you, set the direction explicitly.
Exercise
You mix red (hue about 29) and blue (hue about 264) with color-mix(in oklch, red, blue). Which hue method applies, and roughly what hue does a 50% mix have? What keyword would send the mix through green instead?
Show answer
The default shorter hue applies. It uses the 125-degree arc through hue 0, so the midpoint is about 326, a magenta-purple. Adding longer hue (color-mix(in oklch longer hue, red, blue)) uses the 235-degree arc through yellow and green, and the midpoint is about 146, a green. increasing hue gives the same result here, since going upward from 29 to 264 is the long arc.