Design Tool

CSS Gradient Generator

Build linear, radial and conic gradients with live preview — pick colors, set angle, copy CSS

Gradient Settings

Used for Linear and Conic gradients

Live Preview

How This CSS Gradient Generator Works

This tool generates the background CSS property for linear, radial, and conic gradients with a live preview. Pick your colors, add stops, set the angle, and the CSS updates in real time. Click Copy CSS to get the exact property ready to paste into your stylesheet — no vendor prefixes needed for modern browsers.

All generation happens in your browser. There's no server, no account, and no upload. The tool also saves your last gradient in localStorage so it's still there if you close the tab.

How to Use This Tool

  1. Choose a gradient type — Linear (straight line), Radial (circle from center), or Conic (rotation around a point)
  2. Pick your start and end colors using the color pickers
  3. Click + Add Color Stop to insert additional colors between your start and end
  4. Drag the angle slider to rotate linear and conic gradients
  5. Click Copy CSS to copy the generated background property

CSS Gradient Types — Complete Reference

Type CSS Function Direction Best For
Linear linear-gradient() Straight line at any angle Backgrounds, hero sections, buttons
Radial radial-gradient() Outward from center point Spotlight effects, vignettes, buttons
Conic conic-gradient() Rotation around a center point Pie charts, color wheels, spinners
Repeating Linear repeating-linear-gradient() Tiling straight line Stripes, patterns, textures

CSS Gradient Code Examples

Copy any of these directly into your CSS:

/* Simple two-color linear */
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

/* Top to bottom fade */
background: linear-gradient(to bottom, #4facfe 0%, #00f2fe 100%);

/* Three-stop rainbow */
background: linear-gradient(90deg, #f093fb 0%, #f5576c 50%, #4facfe 100%);

/* Fade to transparent (overlay) */
background: linear-gradient(to bottom, rgba(0,0,0,0.7), rgba(0,0,0,0));

/* Radial spotlight */
background: radial-gradient(circle at center, #ffffff 0%, #e0e7ff 60%, #6366f1 100%);

/* Conic color wheel */
background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);

Common Angle Values for Linear Gradients

Angle Keyword Equivalent Direction
0degto topBottom → Top
90degto rightLeft → Right
135degto bottom rightTop-left → Bottom-right
180degto bottomTop → Bottom
270degto leftRight → Left

5 Tips for Better CSS Gradients

  1. Use 3-stop gradients for depth — a midpoint stop lets you control the "weight" of the transition. Push it toward one end to create a fast fade or a slow one
  2. Avoid pure black in gradientsrgba(0,0,0,0) at one end often produces a grey muddy middle. Use the actual hue at low opacity instead (e.g. rgba(79,70,229,0))
  3. Use to bottom not 180deg — keyword directions are more readable and mean the same thing, making your CSS easier to maintain
  4. Layer gradients for texture — CSS supports multiple backgrounds: background: linear-gradient(...), linear-gradient(...) — the first listed is on top
  5. Test at different viewport sizes — radial and conic gradients can look very different on mobile vs desktop depending on the element's aspect ratio

Frequently Asked Questions

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

Linear gradients flow along a straight line at a set angle — the most common type for backgrounds and buttons. Radial gradients expand outward from a center point, useful for spotlight and vignette effects. Conic gradients rotate around a center point like a color wheel, mainly used for pie charts and spinner animations.

Can I use more than 2 colors in a CSS gradient?

Yes, there's no limit on color stops. Each stop is a color value followed by an optional position: linear-gradient(90deg, red 0%, blue 50%, green 100%). Omitting positions lets CSS distribute stops evenly.

Do CSS gradients work in all browsers?

Linear and radial gradients work in every modern browser with no prefixes needed. Conic gradients require Chrome 69+, Firefox 83+, Safari 12.1+, Edge 79+ — all current versions. No browser in active use today lacks support.

How do I make a transparent gradient overlay?

Use rgba() with alpha 0 for the transparent end: linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(0,0,0,0)). Avoid using the keyword transparent — browsers interpolate it through grey, which looks muddy. Use the actual color at zero opacity instead.

Can I animate a CSS gradient?

Standard transition doesn't work on gradients. The workaround is animating background-position on an oversized gradient, or using the newer @property to register typed custom properties that can be transitioned. The @property approach works in Chrome and Edge; Firefox support arrived in version 128.

What's the difference between background and background-image for gradients?

Gradients are technically images, so they go on background-image. Using the shorthand background works too and is more common. If you set background-image separately, make sure you don't also set background elsewhere or it will override the gradient.

Advanced Gradient Techniques

Once you've got the basics down, these techniques are what separate amateur CSS from genuinely polished UI work. They're not complicated — just patterns most tutorials skip over.

Hard Stops — Creating Stripes and Sharp Edges

A normal gradient blends smoothly between colors. A hard stop makes two colors meet with zero blending — like a sharp line. You do this by giving the same position to two different color stops:

/* Hard stop — sharp dividing line at 50% */
background: linear-gradient(to right, #6366f1 50%, #f59e0b 50%);

/* Diagonal stripes using repeating-linear-gradient */
background: repeating-linear-gradient(
  45deg,
  #6366f1,
  #6366f1 10px,
  #ffffff 10px,
  #ffffff 20px
);

Stripes like this are used constantly for loading states, "under construction" banners, and progress bar textures. The trick is that the repeating version tiles itself automatically — you just define one stripe unit and the browser repeats it across the whole element.

Layering Multiple Gradients

CSS lets you stack multiple backgrounds on a single element, separated by commas. The first one listed sits on top, the last one at the bottom. This is how you get complex layered effects without any images:

/* Dark overlay on top of a colour gradient */
background:
  linear-gradient(to bottom, rgba(0,0,0,0.5), rgba(0,0,0,0)),
  linear-gradient(135deg, #667eea 0%, #764ba2 100%);

/* Noise texture simulation using conic + linear */
background:
  radial-gradient(circle at 20% 80%, rgba(120,119,198,0.3) 0%, transparent 50%),
  radial-gradient(circle at 80% 20%, rgba(255,119,115,0.3) 0%, transparent 50%),
  linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);

That last example is what gives a lot of modern SaaS hero sections their "glowy" look — it's just three gradients stacked. No SVG blobs, no images, just CSS.

Animating Gradients Without @property

Here's something that trips up a lot of developers: transition and animation don't work directly on gradient values. If you try to transition a background gradient, nothing happens. The workaround most people use is the "sliding background" trick:

/* Animated gradient via background-position */
.animated-bg {
  background: linear-gradient(270deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

You make the gradient 400% wide, then animate its position. From the user's perspective it looks like the colors are slowly shifting — which is exactly the effect you want for hero sections and loading screens. This works in every browser, no special support needed.

Browser Support — What Actually Works Where

This is a question that comes up a lot, so here's the real picture. The short version: if you're targeting browsers from the last 3–4 years, you're fine with everything including conic gradients. The only thing to watch out for is the @property trick for animated gradients, which still isn't in Firefox older than version 128.

Feature Chrome Firefox Safari Edge
linear-gradient() 26+ 16+ 6.1+ 12+
radial-gradient() 26+ 16+ 6.1+ 12+
conic-gradient() 69+ 83+ 12.1+ 79+
repeating-linear-gradient() 26+ 16+ 6.1+ 12+
@property (animated gradients) 85+ 128+ 16.4+ 85+

The vendor prefixes (-webkit-linear-gradient etc.) that you might see in older code are no longer needed. Any browser that needs them is so old it represents less than 0.1% of traffic. Just write unprefixed CSS.

Gradients and Accessibility — The Part Most Designers Skip

This one genuinely matters and gets ignored all the time. If you put text over a gradient background, the contrast ratio changes across the element. The left side might pass WCAG AA (4.5:1) and the right side might fail — and most contrast checkers only let you check a single colour at a time.

A few practical rules that will save you from accessibility issues:

  1. Test both extremes. Check the text contrast against the lightest point and the darkest point of the gradient separately. Both need to pass, not just one.
  2. Use a semi-transparent dark overlay. If you need text on an unpredictable background, add linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)) as the topmost layer. It darkens everything uniformly without touching your design gradient.
  3. Avoid light text on light gradients entirely. This seems obvious but a gradient that starts at #ffffff and ends at #e0e7ff (both very light) will fail contrast against white text across its entire length.
  4. Don't rely on gradient alone to convey meaning. If you're using a red-to-green gradient as a "severity scale", colour-blind users won't read it correctly. Add labels or patterns.

Gradients vs Background Images — When to Use Which

This is a practical performance question. CSS gradients are rendered by the browser's paint engine — they have zero bytes of download cost and scale perfectly to any resolution. A PNG or JPEG background image has a file size, needs an HTTP request, and can look blurry on high-DPI (Retina) screens if you didn't export it at 2x.

The cases where you'd still choose an image over a gradient:

For everything else — hero backgrounds, card fills, button styles, divider effects, overlays — a CSS gradient is faster, smaller, and more flexible than any image you could use. It also responds to dark mode and user preferences without you having to manage separate image assets.

Real-World Examples — Gradients You've Definitely Seen

These are production-ready snippets modelled on gradients used across popular design systems and products. Copy them directly and adjust the colors to match your palette.

/* Stripe-style purple hero */
background: linear-gradient(135deg, #635bff 0%, #8b5cf6 100%);

/* Instagram-style warm gradient */
background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);

/* Subtle card background (light mode) */
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);

/* Dark mode deep background */
background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);

/* Green success banner */
background: linear-gradient(90deg, #065f46 0%, #059669 100%);

/* Glassmorphism card overlay */
background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 100%);
backdrop-filter: blur(12px);

Related Tools