Nimble Toolbox

Make a CSS gradient

Add and drag colour stops along the strip, pick a linear, radial, or conic gradient, and the preview and the CSS follow every change. Paste a gradient from your own stylesheet into the CSS box to load it and keep editing.

Selected stopPress the strip to add a stop, and drag a stop to move it.

How to use it#

  1. Choose Linear, Radial, or Conic above the preview.
  2. Press the strip to add a stop, or use "Add a stop", and drag stops to move them. Set the colour, opacity, and position of the selected stop under "Selected stop". Undo steps back through your changes.
  3. Set the angle, or for a radial gradient the centre; a conic gradient takes a start angle and a centre. Press "Copy CSS", or "Download .css" for a file holding the gradient in a rule. To edit a gradient you already have, paste it into the CSS box.

Linear, radial, and conic#

A linear gradient changes colour along a straight line. Its angle says which way the line points: 0deg runs from the bottom up to the top, 90deg from left to right, and 180deg, the default when no angle is written, from top to bottom. Angles turn clockwise, so 45deg runs from the bottom left to the top right.

A radial gradient spreads out from a centre in rings. An ellipse stretches with the box, so on a wide banner the rings are wide too, while a circle keeps them round. "Reaches" sets where the last stop lands: the farthest corner, the default, fills the box, and the nearest side keeps the whole gradient inside it, with the last colour beyond. The farthest side and the nearest corner fall between those two.

A conic gradient turns around its centre like the hand of a clock, starting at the top unless an angle says otherwise. It draws colour wheels, and with hard stops it draws pie charts. This page writes linear-gradient(), radial-gradient(), or conic-gradient(), which every current browser draws.

Stops, hard edges, and stripes#

Each stop is a colour at a position, and the browser blends between neighbours. Put two stops at the same position and there is no blend at all, only a hard edge: red up to 50% and blue from 50% gives two flat halves. That is how flags, split backgrounds, and pie slices are drawn.

Tick "Repeat the stops across the box" to make a repeating-linear-gradient() or its radial or conic twin. The run from the first stop to the last repeats across the box, so stops from 0% to 10% repeat ten times. Two colours with hard edges between them make a striped background, and at an angle of 45deg they make the diagonal stripes of a progress bar.

Pasting a gradient keeps what this page can edit, -webkit- prefixed ones included. A stop with no position is spread evenly between its neighbours, as a browser spreads it, and a stop with two positions becomes two stops. Positions in pixels, midpoint hints, and colour spaces such as "in oklch" are refused with a message rather than changed quietly.

Transparency and fading to nothing#

Each stop has an opacity, and a stop below 100% is written as rgba() so the page underneath shows through. A gradient from a colour to the same colour at 0% fades an image or a block of text into the background, a common overlay for fading the bottom of a photo under a caption.

The keyword transparent is black at 0% opacity. Current browsers blend towards it without darkening, but some older ones drew a grey band in the middle of the fade. Fading to the same colour at 0% opacity looks right everywhere, so a pasted transparent stop takes the colour of the stop beside it.

Using the CSS#

The CSS box holds a background declaration ready to paste into a rule. A gradient is an image to CSS, not a colour, so it works anywhere an image does: background-image, a second layer over a photo in the same background, a border-image for a gradient border, or a mask. For those, copy the gradient without the background: in front. It does not work in color or background-color.

Gradients cost nothing to download, since the browser draws them, and they stay sharp at any size or screen density. A gradient written in a stylesheet also changes with the box: a linear gradient aimed "to top right" points at the corner of whatever box it fills, so on a wide box its colour bands run flatter than on a square one. This page writes angles in degrees, which stay the same on every box, and says so when a pasted corner direction is turned into one.

Frequently asked questions#

How do I make gradient text in CSS?

#

Set the gradient as the background of the text element, then clip the background to the letters and make the text itself transparent: background-clip: text and color: transparent. Write -webkit-background-clip: text beside it too, which older browsers need. Put a plain colour declaration above the transparent one for browsers that cannot clip, and check the contrast of the lightest part of the gradient against the page.

What angle should a CSS gradient use?

#

180deg, top to bottom, is the default and suits most backgrounds. 90deg runs left to right, and 135deg runs from the top left to the bottom right, the usual diagonal for a hero section or a button. Degrees turn clockwise from 0deg, which points up.

How do I make a pie chart with conic-gradient?

#

Choose Conic and give each slice two stops of one colour, at the start and end of the slice. For a pie that is a third red and the rest blue, give red stops at 0% and 33%, then blue at 33% and 100%, or write 33.33% in the CSS box for an exact third. Add a stop with "Add a stop" and type its position, since two stops at one place sit on top of each other on the strip. Round the box with border-radius: 50% to make the pie.

Why does my gradient show bands?

#

A smooth gradient between two close colours over a large area has more pixels than shades between them, so each shade becomes a visible stripe. It shows most on dark, low-contrast gradients. A middle stop with a slightly different colour, or a little noise laid over the gradient, hides the steps.

Can I edit a gradient I already have?

#

Yes. Paste it into the CSS box, with or without background: in front, and the stops, angle, and centre load into the controls. Undo puts back the gradient you had before the paste.