Home › Design Tools › Gradient Generator

Gradient Generator

Build a CSS linear or radial gradient with 2 to 6 colour stops, then copy the CSS.

Gradient type
Colour stops (2 to 6)

Preview

CSS

The line above is ready to paste into a stylesheet rule. Copy copies the same line.

How to use

  1. Choose Linear or Radial under Gradient type.
  2. For linear, enter an Angle from 0 to 360 degrees. For radial, pick a Shape (circle or ellipse) and set the Centre X and Centre Y as percentages.
  3. Edit each colour stop: choose a colour with the picker or type a hex value, then set its position from 0 to 100.
  4. Press Add stop to add a colour, up to six. Use the remove button on a row to delete one. Two stops are the minimum.
  5. Check the Preview, then press Copy to copy the background line.

Worked example

The default gradient runs at 45 degrees from indigo #4f46e5 at 0% to violet #7c3aed at 100%:

background: linear-gradient(45deg, #4f46e5 0%, #7c3aed 100%);

Change the angle to 180 and the colours flow from top to bottom. Add a third stop, #ec4899 at 60%, and the output becomes linear-gradient(180deg, #4f46e5 0%, #ec4899 60%, #7c3aed 100%), because stops are kept in position order. Switch to radial with an ellipse centred at 30% 40% and the head of the value becomes radial-gradient(ellipse at 30% 40%, ...). Two stops at the same position, such as red at 50% and blue at 50%, make a hard edge with no blending.

How it works

Linear gradients run along the angle you set, where 0 degrees points up and 90 degrees points right. Radial gradients start at the centre point you set. Each colour stop is a colour and a position from 0% to 100%. The list is kept in position order, so the first stop is the one nearest 0%. Stops at the same position make a hard edge.

A colour must be a hex value such as #4f46e5 or #fff. If a value is not valid, the result shows an error and the CSS is not updated until the value is fixed.

The syntax. A gradient is an image, not a colour, so it is used where an image is allowed, such as background or background-image. The browser interpolates between neighbouring stops, by default in sRGB. The full grammar is on MDN for linear-gradient() and radial-gradient(). This page writes the angle in degrees and each stop with a percentage, which is the most readable form. A circle keeps the same radius in every direction, while an ellipse stretches with the shape of the box.

Common mistakes

Frequently asked questions

How many colours can I use?

From two to six stops. CSS allows more, but six covers most designs.

Can I make a gradient with a hard stripe?

Yes. Give two neighbouring stops the same position.

Does it work as a text colour?

Not directly. Gradient text needs background-clip: text in your own CSS, using the line this page gives you.

Are gradients heavy for performance?

No. They are drawn by the browser from a short text value, so they are lighter than an image file.

Is my gradient saved?

No. It lives only in the open page.

Related tools