CSS and Colour tool

CSS Gradient Generator: Linear, Radial and Conic

Make linear, radial and conic CSS gradients. Drag colour stops, start from a preset and copy clean, unprefixed CSS. Runs in your browser.

Last updated

A CSS gradient generator builds the background value for a smooth blend between colours. Choose linear, radial or conic, drag the colour stops, set the angle, and copy CSS that works in every modern browser.

Presets

Colour stops (tap the bar to add, drag to move)

Stop 1 of 2

Blend colours in

CSS

background: linear-gradient(90deg, #facc15 0%, #f472b6 100%);

Everything runs in your browser. Nothing you make is uploaded.

How to use it

  1. Pick a type. Linear blends along a line, Radial spreads out from a point, Conic sweeps round a point.
  2. Edit the stops. Tap an empty part of the bar to add a stop there, then drag it into place. Tap a handle to select it, and change its colour in the box below: any CSS colour works, such as #f472b6, navy, rgb(0 0 0 / 50%) or oklch(70% 0.2 30). Remove deletes the selected stop; a gradient always keeps at least two.
  3. Set the direction. Angle turns a linear gradient; Start angle turns a conic one. Radial and conic gradients also have a Centre, and radial ones a Shape.
  4. Copy CSS. The line under the controls is ready to paste into a rule.

Or start from a preset and change it. On a keyboard, tab to a stop handle, move it with the arrow keys (Shift for steps of 10), and press Delete to remove it.

Everything runs in your browser. Nothing you make is uploaded.

The three gradient functions

/* Along a line, at an angle */
background: linear-gradient(135deg, #ff7e5f 0%, #feb47b 100%);
 
/* Out from a point: a circle or an ellipse */
background: radial-gradient(circle at 50% 30%, #ffffff 0%, #93c5fd 40%, #1e3a8a 100%);
 
/* Round a point, like a clock hand */
background: conic-gradient(from 90deg, #ff0000 0%, #0000ff 100%);

Linear gradient. The angle is the direction of travel: 0deg goes up, 90deg goes right, and 180deg, the default, goes down. The gradient line is long enough that the first and last colours reach the corners at any angle.

Radial gradient. circle keeps the rings round; ellipse, the default, stretches them to the box's proportions. at 50% 30% moves the centre. By default the last stop lands on the farthest corner.

Conic gradient. Positions go round the centre rather than out from it, so 25% is a quarter turn. from 90deg rotates the start from the top to the right. Give the last stop the same colour as the first, as the Colour wheel preset does, or there is a visible seam at the top.

Colour stops

A stop is a colour and a position. The browser blends between neighbouring stops and holds the first and last colours out to the edges.

  • Hard edges. Two stops on the same position switch colour with no blend. The Pie chart preset is three hard-edged slices: conic-gradient(#f472b6 0% 40%, #facc15 40% 70%, #38bdf8 70% 100%) is the short way to write the same thing.
  • Fading to transparent. A stop with alpha fades whatever is behind it into view. The tool prints see-through stops as eight-digit hex (#000000cc), and the Fade out preset is the classic dark scrim for text over photos.
  • Stops are drawn in position order. CSS clamps a stop that comes before the one ahead of it, so the tool always prints them sorted.

Smoother blends with in oklab

Blending in sRGB, the default, draws a straight line between two colours in RGB space. Between opposites, like blue and yellow, that line passes through grey, so the middle of the gradient looks muddy.

background: linear-gradient(90deg in oklab, blue, yellow);

in oklab tells the browser to blend in OKLab, a colour space built so equal steps look equal, and the middle stays bright. It is part of CSS Images Level 4 and works in every current browser. Switch Blend colours in to OKLab to compare. The Color Converter explains OKLab and OKLCH, and converts any stop colour to the other formats.

Gotchas

  • A gradient is an image. background-color: linear-gradient(...) does nothing. Use background or background-image.
  • Short elements show short gradients. A gradient sizes itself to the box. On body with little content it repeats in bands; give html a min-height: 100% or the element a height.
  • Text on a gradient needs checking at both ends. Contrast changes along the gradient, so check your text against the lightest and the darkest stop in the Contrast Checker.
  • Gradients cannot be transitioned directly. Animating from one gradient to another jumps. Animate background-position on an oversized gradient, or register a custom property with @property and animate that.
  • No prefixes needed. -webkit-linear-gradient is legacy, and its angles run the other way. Leave it out.

Keep going

The Color Converter turns any stop colour into HEX, RGB, HSL and OKLCH, and the Contrast Checker tells you whether text on your gradient is readable. The CSS cheat sheet covers background and the rest of the properties a gradient sits beside. More free tools that run in your browser are on the tools page.

Common questions

How do I make a gradient in CSS?

Set a gradient function as the background: background: linear-gradient(90deg, #facc15 0%, #f472b6 100%); blends yellow into pink from left to right. A gradient is an image, not a colour, so it goes in background or background-image, not background-color. This CSS gradient generator builds the value for you: pick the colours, drag the stops, and copy the line.

What is the difference between linear, radial and conic gradients?

A linear gradient blends along a straight line at an angle. A radial gradient spreads out from a centre point in a circle or an ellipse, which suits glows and spotlights. A conic gradient sweeps round a centre point like the hands of a clock, which suits colour wheels and pie charts. All three take the same list of colour stops.

How do I use the linear gradient generator angle?

The angle is the direction the gradient travels. 0deg runs from bottom to top, 90deg from left to right, 180deg from top to bottom (the default when you give no angle) and 270deg from right to left. Keywords such as to right do the same job, and to top right aims at the corner whatever shape the box is.

What do the percentages in gradient CSS mean?

Each colour stop's position along the gradient: 0% is the start and 100% the end. Between two stops the colours blend. Two stops at the same position make a hard edge with no blend, which is how stripes and pie charts are drawn. A stop without a position is spaced evenly between its neighbours.

Do CSS gradients still need -webkit- prefixes?

No. Unprefixed linear-gradient, radial-gradient and conic-gradient work in every browser in use today, so this generator prints no vendor prefixes. The old -webkit-gradient syntax and its reversed angles are only needed for browsers more than ten years old.

Why does my gradient go grey in the middle?

By default the browser blends in sRGB, and the straight line between two opposite colours such as blue and yellow passes through grey. Adding in oklab to the gradient, as in linear-gradient(90deg in oklab, blue, yellow), blends in a colour space built to match what the eye sees and keeps the middle bright. The Blend colours in switch in the tool adds it for you.

Is anything I make sent to a server?

No. The gradient is built and previewed in your browser and the colours are never submitted anywhere. The site records that the tool was used, the gradient type and how many stops it had, so we know which tools are worth building next. The colours themselves are never part of that.

See all tools

Want this explained by a cat?

The videos cover the same ground in sixty seconds. If there is a tool you want built next, ask.