The middle of a gradient is a decision

Write a gradient from blue to yellow and the middle comes back grey. Nobody picked that grey. The interpolation did.
It's easy to treat a gradient as a shape: linear, radial or conic, two stops, done. The shape is configuration. The colors between the stops come from the color space the browser mixes in, and that choice gets made whether you make it or not.
#Look at the middle, not the ends
Take one pair of stops and render it in three spaces. The ends are identical. Only the middle changes.
in srgb: middle lightness 0.72, chroma 0.02. in oklab: middle lightness 0.72, chroma 0.02. in oklch: middle lightness 0.72, chroma 0.11.
In sRGB, the browser mixes the encoded red, green and blue numbers. Those numbers aren't spaced the way we see, so colors from opposite sides of the wheel meet near grey, and the middle often sits a little darker than the ends.
Oklab is built so equal steps look roughly equal, and lightness moves evenly from one stop to the other. But it still draws a straight line between the two colors, and between opposite hues that line passes close to grey. Oklab fixes the dip in lightness. It doesn't fix the grey.
OKLCH mixes lightness, chroma and hue separately. Chroma, how colorful a color is, stays up the whole way, so there's no grey. To get there, the hue walks around the wheel and passes through hues neither stop had.
With two blues, all three spaces agree. The choice only shows when the stops are far apart on the wheel.
I take the most visible gradient and render it three times, in srgb, in oklab and in oklch, and look only at the middle third.
#Hex stops still mix in sRGB
CSS mixes in Oklab by default, but only when one of the stops uses a newer color syntax, like oklch(). If every stop is a hex value, a named color, rgb() or hsl(), the browser keeps the old sRGB mixing, so pages written before the newer spaces existed don't change.
/* sRGB: every stop is a legacy color */
background: linear-gradient(to right, #5182c1, #e7cc76);
/* Oklab, because it says so */
background: linear-gradient(to right in oklab, #5182c1, #e7cc76);
So a codebase full of hex colors mostly mixes in sRGB. Writing the space costs a few characters, and the next person reads a decision instead of a default.
color-mix() asks the same question in a different place. The space is its first argument, as in color-mix(in oklab, var(--blue), var(--yellow)). A hover shade made with color-mix() is a gradient you only sample once, and the space changes it the same way.
I list the gradients that don't name a space.
grep -rEn '(linear|radial|conic)-gradient\(' src | grep -v ' in '
For each one, decide whether sRGB is what you want. If it is, write in srgb so it's on the page.
#OKLCH has to pick a way around the wheel
Hue is an angle, and between two angles there are two ways around the circle. OKLCH has to take one. By default it takes the shorter one. longer hue takes the other. increasing hue and decreasing hue fix the direction, no matter which way is shorter.
in oklab: the middle is greyish brown, hue 56 degrees, chroma 0.03.
Coral to teal shows all three. The straight Oklab line cuts through the middle of the wheel, and the middle turns a greyish brown. The shorter way around passes through yellow, and the middle turns olive. The longer way passes through blue, and the middle is a soft violet. Same two stops, three different middles.
Sometimes the hues on the way are the effect. A hue picker or a rainbow ring wants the long way round. In a button or a page background, a hue nobody chose is usually the bug.
For every in oklch gradient, I find the hues that sit between the stops on the shorter path. If one would surprise me, I try longer hue, or pick the middle myself.
#When no space gives the right middle, pick it
Sometimes sRGB is muddy, Oklab goes grey and OKLCH visits a hue you don't want. Then stop asking the browser for the middle and give it one.
There are two tools for that, and only one of them changes the color. A color hint is a bare percentage between two stops, like #5182c1, 30%, #e7cc76. It moves where the halfway color lands. The grey moves with it and stays grey. A third stop is a color you chose. The browser then only mixes the two shorter steps on either side of it, and short steps between near hues don't go grey.
Stops #5182c1, #e7cc76 in Oklab. Lowest chroma 0.02 at 50 percent.
Two stops at the same position make a hard edge: #5182c1 50%, #e7cc76 50%. Nothing gets mixed, so there's no space to choose. That's right for ticks, flags and segmented bars, where the edge is the point.
Radial and conic gradients have defaults of their own: the center, the size, the start angle. If one of those matters, set it. Otherwise you didn't design that part. You inherited it.
If I've been nudging the stops of a gradient and the middle still looks wrong, I add a third stop with the color I want there, and see if the nudging is still needed.
#When this is overkill
When the stops are close in hue, like two blues, or two greys, every space gives almost the same result. You won't see a difference, so don't spend time comparing.
A faint wash at low opacity behind content hides most of this too, and so does a gradient nobody looks at closely, like a divider fading out at its ends.
It matters when the gradient is large and saturated and its stops sit far apart on the wheel. A big background, a brand mark, a chart's color scale where the middle has to mean something.
#What I'm trying next
Next I'm going to write the space into every gradient and color-mix() I touch, in srgb included, so the choice is visible instead of inherited.
What I don't know yet is how to handle gradients with many stops. CSS takes one space for the whole gradient, and some segments would look better in Oklab while others want OKLCH. My guess is more stops, each segment short enough that the space barely matters. I haven't tried that on a real palette yet.
The space is a decision. Write it down.