Skip to the content

CSS Gradient Generator

Design linear, radial and conic gradients and copy the CSS.

°
Color stops

Drag a handle to move a stop. Click the bar to add one.

Presets

Share this tool:TwitterFacebookLinkedInWhatsAppEmail

How a CSS gradient is written

A gradient is an image that the browser draws itself, so it goes wherever an image can go, most often in background. All three kinds are written the same way: first how the gradient lies in the box, then a list of colors.

background: linear-gradient(
  135deg,
  #f97316,
  #ec4899 60%,
  #7c3aed
);

135deg is the direction the colors travel in. Angles count clockwise from straight up, so 0deg runs to the top, 90deg to the right and 180deg to the bottom. After that come the color stops: orange at the start, pink at 60% of the way, violet at the end.

FunctionWhat comes before the colors
linear-gradient()The direction: 90deg
radial-gradient()The shape and the center: circle at 30% 30%
conic-gradient()The start angle and the center: from 45deg at 30% 30%

The generator leaves out whatever a browser assumes anyway: 180deg, the ellipse shape, a center in the middle, a start at 0deg.

Where the stops end up

A first stop without a position sits at 0% and a last one at 100%. Stops in between that have no position are spread evenly, which makes red, gold, green the same as red 0%, gold 50%, green 100%. Before the first stop and after the last one the color just carries on, flat.

What 100% means depends on the kind of gradient. In a linear gradient it is the far side of the box in the chosen direction, or the far corner when the direction is diagonal. In a radial gradient it is the corner farthest from the center, unless you set a size. In a conic gradient the positions run around the center like the hands of a clock, so 25% is a quarter turn.

Hard stops for stripes

Give two stops the same position and the color changes on the spot instead of fading. In the tool you do that by dragging one handle onto another, or by typing the same position twice. The stop that is listed first is the color before the edge.

background: linear-gradient(
  90deg,
  #7c3aed 33.33%,
  #a78bfa 33.33% 66.67%,
  #ddd6fe 66.67%
);

A color with two positions, as in the middle here, is short for two stops of that color: a solid band. The same trick in a conic gradient gives the slices of a pie chart.

Fading out

To let a color fade away, keep the color and bring its opacity down to 0. Fading to a different transparent color also works in current browsers, because they weigh each color by its opacity while mixing. Safari did not do that before version 15, and showed a grayish band in the see-through part.

Mixing in OKLCH

Colors written as hex or rgb() are mixed in sRGB. Between two hues that lie far apart, such as blue and yellow, that produces a dull gray halfway. Adding in oklch makes the browser travel around the color wheel instead, in this case through green:

background: linear-gradient(
  90deg in oklch,
  #2563eb,
  #facc15
);

This works from Chrome and Edge 111, Safari 16.2 and Firefox 127. An older browser ignores the whole declaration, which is where a plain color on the line before still earns its place. The generator does not write in oklch itself; add it by hand after the direction.

Sharing a gradient

The address of this page changes along with the gradient. Bookmark it, or use Copy link, and the same gradient comes back when the link is opened.

See all 8