CSS Gradient Generator

Build linear, radial and conic CSS gradients with draggable colour stops, blend in sRGB, OKLab or OKLCH to avoid the grey middle, and copy CSS with a fallback for older browsers.

Generator Color & Design Updated Oct 3, 2026
Learn how this works
How to Use
  1. Choose Linear, Radial or Conic, and set the angle or shape.
  2. Edit the colour stops: type any CSS colour or use the picker, and drag the handles on the bar to move them. Click the bar to add a stop there.
  3. Choose how colours blend: sRGB (the browser default), OKLab (even, no grey middle) or OKLCH (keeps colours vivid, travels round the colour wheel).
  4. The strip under the preview shows the same stops in all three blends, so you can compare.
  5. Copy the CSS. For OKLab and OKLCH it starts with a plain fallback line for browsers older than 2023.
Input
0° up, 90° right
135°
drag handles · click bar to add
Presets
Preview
Stops
—
Midpoint
—
Saturation dip
—
CSS size
—

Worked Example

A gradient from pure blue #0000FF to pure yellow #FFFF00, looked at halfway along.

sRGB averages each channel: red (0 + 255) ÷ 2 = 127.5, green the same, blue (255 + 0) ÷ 2 = 127.5. The middle is rgb(128, 128, 128), #808080 — flat grey, with no colour at all.

OKLab averages perceptual lightness and the two colour axes instead, giving #6CABC7, a soft sky blue that still has colour. OKLCH blends the chroma and turns the hue the short way round the wheel from blue (264°) to yellow (110°), so the middle is #00CFBD, a vivid teal — as saturated as a screen can show that hue at that lightness. The comparison strip under the preview shows all three at once.

Show Work

Build a gradient above to see how it is blended.

Formulas

sRGB blend
c = c1 + (c2 − c1)·t
Each of R, G, B separately, on gamma-encoded values
OKLab blend
L, a, b each blended linearly
Straight line through a perceptual space
OKLCH blend
L, C blended; hue the shorter way
Δh kept within ±180°
Linear angle
0° ↑ · 90° → · 180° ↓
The direction the gradient travels towards
Hard edge
A p%, B p%
Two stops at the same position

From Image Slices to Colour Spaces

Early web gradients were 1-pixel-wide image slices repeated across a box. WebKit introduced CSS gradients in 2008 with its own syntax, and after years of vendor prefixes the standard linear-gradient() and radial-gradient() were supported everywhere by 2013. conic-gradient() followed in all major browsers by 2020.

All of them blended in gamma-encoded sRGB, which is why designers learned to add a middle stop to avoid grey. CSS Color Level 4 added the “in <colour space>” keyword, shipped across browsers in 2023, letting a gradient blend in OKLab or OKLCH so it looks the way people expect a blend between two colours to look.

About This Tool

This tool builds linear, radial and conic gradients from any number of colour stops in any CSS colour format, with draggable stop handles, hard stops and repeating gradients. It blends in sRGB, OKLab or OKLCH, compares all three on a strip, and measures the midpoint colour and how much saturation the blend loses.

For OKLab and OKLCH the copied CSS starts with a fallback that samples the blend into extra sRGB stops, so older browsers show nearly the same gradient. Everything runs in your browser.

Related tools: CSS Pattern Generator, Color Palette Generator, and Box Shadow Generator.

Frequently Asked Questions

Why does my gradient look grey or muddy in the middle?

By default browsers blend the red, green and blue numbers separately. Halfway between blue (0, 0, 255) and yellow (255, 255, 0) is (128, 128, 128): plain grey. Blending in OKLab follows how we see lightness and passes through a much cleaner colour, and OKLCH keeps colours as saturated as the screen allows by travelling around the hue circle.

What is the difference between OKLab and OKLCH blending?

OKLab blends in a straight line through a perceptual colour space: smooth and even, slightly less saturated in the middle when the ends are opposite hues. OKLCH blends lightness, chroma and hue separately, so saturation stays high and the hue swings around the wheel — blue to yellow goes through green. Choose OKLab for subtle backgrounds and OKLCH for vivid, rainbow-like ones.

What do the angles mean?

For linear gradients 0° points up (the gradient runs bottom to top), 90° points right, 180° down and 270° left. Conic gradients start at the given angle and sweep clockwise around the centre. Radial gradients have no angle; they spread out from the centre as a circle or an ellipse that fits the box.

How do I make hard edges instead of a smooth blend?

Put two stops at the same position. Blue at 0% and 50% followed by white at 50% and 100% makes a sharp half-and-half split; that is how CSS stripes and flags are drawn.

Do “in oklab” gradients work everywhere?

They are supported in all major browsers since 2023 (Chrome 111, Safari 16.2, Firefox 127). Older browsers ignore that line, so the copied CSS begins with a fallback: the same gradient sampled into extra sRGB stops, which looks almost identical everywhere.

How do I use the CSS Gradient Generator?

Simply pick your options and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.

Does it cost anything or need an account?

No. The tool is completely free, there is no account to create, and it keeps working offline after the page first loads.

Is anything I type uploaded?

No. The tool works entirely on your device, so the values you enter never leave your browser.

Common Use Cases

Hero backgrounds

A two-colour linear gradient at 135°, blended in OKLab, gives a smooth brand background without a grey band.

Buttons and cards

A subtle 180° gradient between two shades 5–10% apart in lightness adds depth to a button.

Glows and spotlights

A radial gradient from a colour to transparent makes a soft glow behind an icon or heading.

Charts and colour wheels

A conic gradient with hard stops draws a pie chart; a conic rainbow in OKLCH draws an even colour wheel.

Last updated: