CSS Gradient Generator

Build a linear, radial or conic CSS gradient with live preview, a flat colour fallback, and the stop control that decides where the blend happens.

Enable JavaScript to change the gradient; the CSS below is for the defaults.

Type

Linear blends along a line, radial outwards from a point, conic around one.

0 points up, 90 points right. Used by linear and conic gradients.

Where a radial or conic gradient starts from.

Radial shape

An ellipse stretches with the element; a circle stays round.

Everything before this position is the flat first colour.

Preview
gradient.css
.your-element {
	background-color: #1e56ec;
	background-image: linear-gradient(135deg, #1E56EC 0%, #0B1020 100%);
}

Build a linear, radial or conic gradient, watch it fill a real element, and copy it with a flat colour fallback in front.

How to use

  1. Pick the type. Linear blends along a line, radial spreads outwards from a point, conic sweeps around one.
  2. Set the angle for linear: 0 points up, 90 points right, 135 gives the diagonal most interface gradients use.
  3. Move the stops rather than adding colours. A blend that looks muddy usually needs its two stops pulled apart, not a third colour.
  4. Add a middle colour when the blend passes through a hue you do not want. Blue to orange goes through grey; a middle stop steers it.
  5. Keep the flat colour fallback in the output. It is what shows if the gradient fails to parse, and it is what the text has to be readable against.

Example

.your-element {
	background-color: #1e56ec;
	background-image: linear-gradient(135deg, #1E56EC 0%, #7A5AF8 50%, #0B1020 100%);
}

The first stop at 0% and the last at 100% means the blend uses the whole element. Pull them in to 20% and 80% and you get flat colour at each end with the blend in the middle.

Pitfalls

  • Two colours far apart in hue blend through grey. Blue to yellow passes through a dull green; a middle stop is how you avoid it.
  • Gradients are background-image, not background-color. Anything relying on background-color alone, including some email clients, sees nothing without the fallback.
  • Text on a gradient has a different contrast ratio at each end. Check the worst point, not the middle.
  • repeating-linear-gradient needs its last stop well below 100 percent, or there is nothing left to repeat and it looks identical to the plain version.
  • An ellipse radial gradient stretches with the element, so the same CSS looks different in a wide box and a tall one. circle stays round.
  • Banding shows on large, subtle gradients, particularly in dark colours on 8 bit displays. A little noise or a third stop hides it.
  • Animating a gradient means repainting the whole element each frame. Animate a transform on a gradient-filled overlay instead.
  • Conic gradients need Chrome 69, Firefox 83 or Safari 12.1. Everything older shows the fallback colour.

Compatibility

linear-gradient and radial-gradient are supported by every browser in use, unprefixed since 2013. conic-gradient needs Chrome 69, Firefox 83 or Safari 12.1. The repeating- variants have the same support as their base. Stops in percentages work everywhere; the newer interpolation hints and colour space syntax do not, and are not used here. The tool runs entirely in your browser.

Frequently asked questions

Why does my gradient look muddy?
The two colours are blending through a neutral. Add a middle stop in the hue you want it to pass through.
Why is there a background-color too?
As a fallback. If the gradient cannot be rendered, the element still has a sensible colour rather than none.
How do I make stripes?
Use a repeating gradient with two stops close together and a last stop well short of 100 percent.
Can I use a gradient on text?
Yes, with background-clip: text and a transparent text colour. Keep a solid colour fallback, because unsupported browsers show nothing.
Which type should I use?
Linear for backgrounds and buttons, radial for spotlights and vignettes, conic for pie charts and colour wheels.
Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.