Design Tool

CSS Gradient Generator — Linear & Radial, Copy Code Free

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

AllOmnitools Editorial Team

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.

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

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:

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:

  • You need a photographic texture (concrete, fabric, paper grain)
  • You want a specific artistic design that's too complex to recreate in CSS
  • You're working with a brand asset that must match exactly across print and digital

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);

How to Use This Tool

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

FAQ

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.