CSS gradient generator — linear, radial and conic, with live preview

Type your colour stops, choose a gradient type and angle, and copy ready-to-use CSS, with a solid fallback colour and a live preview of the result.

Live demo · real result from this tool
Type
0° points up and angles turn clockwise: 90° runs left to right.

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use the CSS gradient generator

  1. Pick a Type: Linear, Radial or Conic.
  2. For linear and conic gradients, drag the Angle slider. For radial and conic, choose the Centre; radial also has a Shape (circle or ellipse).
  3. In Colour stops, write one colour per line, optionally followed by a position such as 50% or 10px.
  4. Choose an Interpolation space if you want smoother blends, and tick Repeating gradient for patterns.
  5. Watch the preview update, then copy the CSS.

What it does and when to use it

The generator writes the background CSS for three kinds of gradient. A linear gradient blends along a straight line, which suits hero banners, buttons and overlays that darken the bottom of a photo. A radial gradient spreads out from a centre point, good for spotlights and soft glows. A conic gradient sweeps around a centre like a clock hand, which is how pie-chart-style rings and colour wheels are drawn in pure CSS.

It reads any CSS colour you type, including names, rgb(), hsl() and oklch(), and writes opaque colours back as hex. Stops with transparency are written as rgba(). If a colour is not recognised, it tells you which line is wrong.

To choose the colours themselves, start with the colour picker or turn a value into hex with the colour converter. If text will sit on top of the gradient, check it against the lightest and darkest parts with the contrast checker.

How it works

The tool parses each stop line, reads up to two trailing positions (bare numbers become percentages), and checks that the colour is valid. It then builds the CSS function: linear-gradient(<angle>deg, …), radial-gradient(<shape> at <centre>, …) or conic-gradient(from <angle>deg at <centre>, …), adding repeating- and in <space> when you ask for them. The first stop’s colour is written as a separate fallback line above it. Everything runs in your browser; the preview is a small sandboxed frame using the same CSS.

Worked examples

Each CSS line below is the generator’s own output.

A blend that avoids grey. Linear, 90°, stops #3b82f6 and #facc15, Interpolation OKLab, gives background: linear-gradient(90deg in oklab, #3b82f6, #facc15);

A colour wheel. Conic, 0°, centre, with the stops red, yellow, lime, aqua, blue, magenta and red again, gives conic-gradient(from 0deg at center, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000). Repeating red at the end closes the circle without a seam.

Diagonal stripes. Linear, 45°, Repeating ticked, stops #000 0 10px and #fff 10px 20px, gives repeating-linear-gradient(45deg, #000000 0% 10px, #ffffff 10px 20px).

Limits and tips

  • One gradient at a time. CSS allows several gradients layered with commas; combine outputs by hand if you need that.
  • Stops are typed, not dragged. Move a stop by editing its position. Uneven positions, such as 0%, 20%, 100%, shape the blend more than adding colours does.
  • The fallback works best with a solid first colour. If your first stop is semi-transparent, check the fallback line before you use it.
  • Gradients are images in CSS, so they also work in background-image, border-image and mask-image.
  • For shadows to go with the background, try the box shadow generator.

Frequently asked questions

Which way does 0deg point in a CSS gradient?
Up. In CSS, 0deg runs from bottom to top and angles turn clockwise, so 90deg runs left to right and 180deg top to bottom. This is different from maths, where 0° points right.
Why does the middle of my gradient look grey or muddy?
By default browsers blend colours in sRGB, and the straight line between two opposite colours, such as blue and yellow, passes through grey. Set Interpolation to OKLab or OKLCH and the generator adds "in oklab" or "in oklch", which keeps the middle bright.
How do I make hard stripes instead of a smooth blend?
Give two neighbouring stops the same position, for example "#000 0 10px" and "#fff 10px 20px", and tick Repeating gradient. The colour changes instantly at 10px and the pattern repeats every 20px.
Will older browsers show anything?
The CSS includes a solid fallback line first, using your first colour, so a browser that cannot draw the gradient still shows a background. Gradient interpolation spaces such as "in oklab" are newer than gradients themselves, so check support for your audience.
Can I put a gradient on text?
Yes, with extra CSS. Apply the gradient as the background of the text element, clip the background to the text with the background-clip property set to text, and make the text colour transparent.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close