CSS Gradient Generator

Build linear and radial CSS gradients with two colour stops, an angle slider and a live preview — then copy the code.

Runs in your browserUpdated Built and maintained by Leon and Henrik

Pick your colours, choose linear or radial, set the angle, and copy ready-to-paste CSS from a live preview. Free. No sign-up. Runs in your browser, nothing is uploaded.

CSS Gradient Generator
90°
CSS
background: linear-gradient(90deg, #6366f1, #ec4899);
Runs in your browser
Nothing is uploaded

Choose two colours, pick Linear or Radial, set the angle and copy a ready background: declaration. Need more than two colours? Add up to three extra stops, each with its own position — five colours in total. The preview updates as you drag, and the page address always holds the current gradient, so Copy link shares exactly what you see.

Angles at a glance

AngleDirection of travelKeyword equivalent
0degbottom → topto top
45degtowards the upper right, at 45°(to top right aims at the corner instead)
90degleft → rightto right
135degtowards the lower right—
180degtop → bottom (the default)to bottom
270degright → leftto left

The angle describes where the gradient is heading, measured clockwise from straight up. People often expect 0deg to mean "left to right" because that's how many design apps work; in CSS it points upward.

What the generated CSS looks like

Two colours give the short form:

background: linear-gradient(90deg, #6366f1, #ec4899);

With extra stops, every colour gets a position, sorted from 0% to 100%:

background: linear-gradient(90deg, #6366f1 0%, #ffffff 50%, #ec4899 100%);

The radial option produces radial-gradient(circle, …), a circle centred on the element. To move its centre, edit the copied line to radial-gradient(circle at top left, …) or circle at 30% 20%.

Fixing a muddy midpoint

The most common gradient complaint is the dull band in the middle. It happens because the browser mixes colours channel by channel in sRGB, and opposite hues cancel each other out:

FromToMidpoint the browser shows
#3b82f6 (blue)#f59e0b (amber)#989081 (greyish)
#6366f1 (indigo)#ec4899 (pink)stays colourful — the hues are neighbours

Three ways out:

  1. Add a middle stop with a saturated colour that belongs between the two — for blue to amber, a teal or a pink at 50% keeps it lively.
  2. Choose neighbouring hues. The Color Palette Generator shows analogous colours that blend cleanly.
  3. Interpolate in a perceptual colour space. Modern browsers accept linear-gradient(in oklch 90deg, #3b82f6, #f59e0b), which travels around the colour wheel instead of through grey. Add it by hand to the copied CSS; older browsers will ignore the whole declaration, so keep the plain version as a fallback line above it.

Hard edges and stripes

Two stops at the same position create a sharp line instead of a blend. For example, add two extra stops both at 50% — one in each half's colour — and you get a two-tone split, handy for buttons or section dividers. The swap button flips start and end colours without retyping.

Using gradients behind text

A gradient changes colour across its width, so text contrast changes with it. Check the lightest and the darkest part of the gradient against your text colour separately with the Color Contrast Checker. For large, dark backgrounds, very subtle gradients can show visible "banding" steps on some screens; a slightly bigger colour difference or a faint noise texture hides it.

To convert any stop to RGB or HSL, use the Color Converter. For a frosted-glass card on top of your gradient, the Glassmorphism Generator builds the matching CSS.

Frequently asked questions

Related tools

All Color tools →