CSS Gradient Generator
Linear, radial and conic, without the grey band through the middle.
Build linear, radial and conic CSS gradients with any number of stops, interpolated in OKLCH so the midpoint stays saturated instead of going grey.
Colour stops
Interpolation
Presets
The two interpolation spaces, side by side
OKLCH
sRGB
Measured at the midpoint of the first two stops: chroma 0.000 in sRGB against 0.124 in OKLCH, where the stops themselves carry 0.211. Averaging the red, green and blue channels of two colours on opposite sides of the wheel lands near grey, which is the dead band you can see in the lower strip.
The gradient as swatches
in oklch is part of CSS Color 4 and works in every current browser. It matters most where a gradient crosses the colour wheel: two shades of the same blue interpolate almost identically in either space, which is why the comparison strip only appears when there is a difference to see.
How the CSS Gradient Generator works
The interesting part of a gradient is the middle. Interpolating in sRGB averages the colour channels, and the channel average of two saturated colours on opposite sides of the wheel is close to grey — blue to yellow measures exactly zero chroma at its midpoint. Interpolating in OKLCH keeps it alive, and CSS supports that directly.
Also known as: linear gradient generator · radial gradient generator · conic gradient css · oklch gradient generator · background gradient css
Frequently asked questions
Why does my gradient go grey in the middle?
Because it is being interpolated in sRGB, which averages the red, green and blue channels. Halfway between blue and yellow those averages land almost exactly on grey: measured, the midpoint carries 0.000 chroma where both ends carry 0.211. The colour was never chosen, it simply fell out of the arithmetic. Adding “in oklch” to the gradient interpolates through a perceptual space instead, and the same midpoint keeps 0.124 chroma.
What does 'in oklch' do in a CSS gradient?
It tells the browser which colour space to interpolate through. Without it the default is sRGB, which averages channels; with it the browser walks lightness, chroma and hue separately, so a gradient crossing the colour wheel stays saturated the whole way. It is part of CSS Color 4 and works in every current browser. It makes little difference between two shades of one hue, which is why it is worth reaching for specifically when a gradient crosses the wheel.
What is the difference between shorter and longer hue?
Which way round the colour wheel the gradient travels. Red to blue the short way passes through magenta; the long way goes through green, yellow and orange instead. Shorter is the default and is almost always what you want, but longer is how a rainbow sweep across two nearby hues is made. There are also increasing and decreasing, which force a direction regardless of which is shorter.
Do I need a fallback for older browsers?
Only if you support browsers older than the current generation. If you do, put a plain gradient first and the OKLCH version second: a browser that does not understand the newer syntax ignores that declaration and keeps the earlier one. The fallback offered here is not simply the same gradient without the hint — it carries extra stops sampled along the OKLCH path, so the shape survives even where the syntax does not.
What is a conic gradient?
One that sweeps around a centre point rather than along a line, which is how pie charts, colour wheels and loading spinners are made in pure CSS. The angle sets where the sweep starts. It is the least used of the three and the one that most often removes the need for an image.
How many colour stops should a gradient have?
Usually two or three. Every additional stop is a place the eye can catch a seam, and gradients that look muddy are often over-specified rather than under-specified. If you are adding stops to stop a gradient going grey in the middle, switch the interpolation to OKLCH instead — that is the actual problem, and the extra stops are a workaround for it.
Related calculators
Color Picker
Pick a colour, get every format, and five palettes that hold their hue.
OpenContrast Checker
WCAG pass or fail, and the nearest colour that fixes it.
OpenColour Converter
HEX, RGB, HSL and OKLCH, with a contrast check and a ramp that holds its hue.
Open