CSS Gradient Generator
Beta: this tool hasn't been fully reviewed yet. Double-check results before relying on them.
Inputs
Drag a marker to move its color; click the bar to add a color there.
0 goes up, 90 to the right.
0 is the left edge.
0 is the top edge.
How the in-between colors are mixed.
Results
Drag on the preview to move the center.
CSS
The same colors, three ways
- OKLab
- OKLCH
- sRGB
sRGB mixes the red, green and blue numbers directly, which can dip into gray between opposite colors.
Your input is too long to share as a link, so the page address no longer includes it.
A CSS gradient blends between colors, and how it blends matters. Mixing the red, green and blue values directly (sRGB, what browsers did for years) can make the middle of a blue-to-yellow gradient a dull gray. Mixing in OKLab, a space built around how people see color, keeps it clean, and every current browser supports it.
How to use it
- Set the colors (type them or use the pickers); add up to six. Drag the markers on the bar to move a color, or click the bar to add one in between.
- Pick the shape and the angle. Drag a color’s grip (⠿) to change the order. For radial and conic gradients, drag on the preview to move the center.
- Choose how to blend, compare the three strips, and copy the CSS.
Example: blue #0047ab to gold #ffd700 in sRGB passes through a muddy gray in the middle; in OKLab the middle stays a clear color. The CSS is linear-gradient(in oklab 90deg, #0047ab, #ffd700), with a plain line before it for older browsers. Offset: with blue at 30% and gold at 70%, the first 30% is solid blue and the last 30% solid gold: linear-gradient(in oklab 90deg, #0047ab 30%, #ffd700 70%). Off-center: a radial gradient with its center at 25% across, 25% down is radial-gradient(circle at 25% 25% in oklab, …), like light from the top left.
Questions and answers
Do browsers support "in oklab"?
Yes: current Chrome, Edge, Firefox and Safari all support color spaces in gradients. The CSS here also includes a plain sRGB line first, which older browsers use instead.
OKLab or OKLCH?
OKLab blends in a straight line between the colors: smooth and natural. OKLCH travels around the hue wheel, so red to blue passes through purple and pink at full strength: more vivid, sometimes surprising.
How do I make a hard stripe instead of a blend?
Put two colors at the same position: drag one marker onto the other, or type the same number in both position boxes. The CSS then reads like linear-gradient(90deg, red 50%, blue 50%).
Link with pre-filled values
Add # and these parameters to the end of this page's address to open the tool with values already filled in.
| Parameter | What it sets |
|---|---|
colors | 2 to 6 colors, separated by commas, each optionally followed by its position from 0 to 100 (write # as %23 and the space as %20 in a link). |
type | linear, radial or conic. |
angle | Angle in degrees (linear and conic). |
space | Blend in oklab, oklch or srgb. |
x | Center of a radial or conic gradient, across, from 0 (left) to 100 (right). |
y | Center of a radial or conic gradient, down, from 0 (top) to 100 (bottom). |