CSS Gradient Generator: Create Beautiful Gradients Without Writing Code
Visually build linear, radial, and conic CSS gradients with a live preview. Copy production-ready CSS with one click — no design software needed.
CSS gradients are one of the most powerful and underused tools in the frontend developer's toolkit. They let you create smooth color transitions, dramatic backgrounds, subtle UI polish, and even complex visual patterns — all without a single image file. Before CSS gradients became universally supported, designers had to export gradient backgrounds as PNGs from Photoshop, resulting in extra HTTP requests, inflexible static assets, and layouts that broke the moment someone changed the brand colors. Today, a single line of CSS replaces all of that.
This guide covers everything you need to know about CSS gradients — the three types, the angle system, real-world use cases with copy-ready code, common mistakes, and how to use the SoftStash CSS Gradient Generator to build exactly what you need without writing a single line from scratch.
Why CSS Gradients Replaced Image-Based Backgrounds
The old approach — exporting a 1×1000px gradient PNG and tiling it horizontally — had real costs. Every gradient was a round-trip to the server, a bytes-on-the-wire cost, and a maintenance burden when colors changed. More importantly, PNG gradients could not respond dynamically to screen sizes, theme switches, or hover states.
CSS gradients solve all of this. They are rendered by the GPU in real time, respond instantly to JavaScript state changes, scale perfectly at any resolution, work with CSS transitions and animations, and add zero bytes to your asset bundle. Browser support is now 100% across all modern browsers and has been since 2014. There is no reason to use image-based gradients for solid color transitions in new projects.
The Three Types of CSS Gradients
1. Linear Gradient
A linear gradient transitions colors along a straight line. The direction can be any angle, or expressed as a keyword like to right or to bottom right. This is the most commonly used gradient type and covers the vast majority of design needs.
/* Classic diagonal purple gradient */
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
/* Top to bottom (default direction) */
background: linear-gradient(#f8fafc, #e2e8f0);
/* Left to right with three color stops */
background: linear-gradient(to right, #f97316, #ec4899, #8b5cf6);2. Radial Gradient
A radial gradient radiates outward from a center point. By default it forms an ellipse that fits the element's bounding box, but you can control the shape, size, and position. Radial gradients are ideal for spotlight effects, glowing buttons, and ambient light simulations.
/* Circular glow from center */
background: radial-gradient(circle, #6366f1 0%, #1e1b4b 100%);
/* Ellipse glow at top-left corner */
background: radial-gradient(ellipse at top left, #fbbf24 0%, transparent 60%);
/* Positioned spotlight */
background: radial-gradient(circle at 30% 40%, #e0f2fe, #0284c7);3. Conic Gradient
A conic gradient sweeps colors around a center point, like the hands of a clock. This makes it uniquely suited for pie charts, color wheels, and loading spinner animations. It was the last of the three gradient types to gain universal support, landing in all major browsers by 2021.
/* Pie chart with three segments */
background: conic-gradient(
#6366f1 0deg 120deg,
#ec4899 120deg 240deg,
#f97316 240deg 360deg
);
/* Color wheel */
background: conic-gradient(
hsl(0, 100%, 50%),
hsl(60, 100%, 50%),
hsl(120, 100%, 50%),
hsl(180, 100%, 50%),
hsl(240, 100%, 50%),
hsl(300, 100%, 50%),
hsl(360, 100%, 50%)
);Understanding the Angle System for Linear Gradients
The angle parameter in linear-gradient follows a convention that surprises many developers because it differs from standard mathematical angles. Here is the mapping:
- 0deg — bottom to top (the gradient flows upward)
- 90deg — left to right (the most common horizontal gradient)
- 135deg — diagonal, top-left to bottom-right
- 180deg — top to bottom (same as the default with no angle specified)
- 225deg — diagonal, bottom-right to top-left
- 270deg — right to left
The keyword equivalents — to top, to right, to bottom left — are often more readable than numeric angles for common directions. For precise diagonal effects, numeric degrees give you exact control. The popular purple-to-indigo diagonal gradient uses 135deg:
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);Radial Gradient Shapes: Circle vs Ellipse
By default, radial-gradient produces an ellipse sized to fit the element. You can override this with two shape keywords:
- circle — forces a perfect circle regardless of the element's aspect ratio. Use this for glow effects and spotlight backgrounds where you want even radial falloff in all directions.
- ellipse — the default, stretches to fit the container. Use this for subtle background fills that need to adapt naturally to any element shape.
The at keyword lets you reposition the gradient center anywhere in the element using any CSS length or percentage. at center, at top left, at 20% 80% — all are valid. Positioning is especially powerful for creating off-center ambient light effects:
/* Glow coming from upper-right corner */
background: radial-gradient(ellipse at top right, rgba(251,191,36,0.4), transparent 60%);
/* Multiple radial gradients layered */
background:
radial-gradient(circle at 20% 30%, rgba(99,102,241,0.3), transparent 40%),
radial-gradient(circle at 80% 70%, rgba(236,72,153,0.3), transparent 40%),
#0f172a;Conic Gradients for Pie Charts and Loading Spinners
The conic gradient's ability to sweep in a circle makes it the native CSS solution for two classic UI components that previously required SVG or JavaScript:
For a progress ring, combine a conic gradient with a circular mask. For a pie chart, the conic gradient segments correspond directly to data percentages. A segment spanning from0deg to 72deg represents exactly 20% of a full circle. This makes translating data to CSS straightforward — multiply the percentage by 3.6 to get the degree value.
Multi-Stop Gradients and Hard Stops for Stripe Patterns
Color stops do not have to blend smoothly. When two adjacent stops share the same position, the transition between them becomes instantaneous — a hard stop. This technique is how you create striped patterns, checkerboards, and ruled line backgrounds entirely in CSS:
/* Candy stripe pattern using hard stops */
background: linear-gradient(
45deg,
#6366f1 25%,
transparent 25%,
transparent 50%,
#6366f1 50%,
#6366f1 75%,
transparent 75%
);
background-size: 40px 40px;
/* Warning stripe — alternating color hard stops */
background: repeating-linear-gradient(
-45deg,
#fbbf24,
#fbbf24 10px,
#1e293b 10px,
#1e293b 20px
);Real-World Use Cases with Example Code
Hero Section Backgrounds
A multi-stop linear gradient with a mesh of two radial highlights gives hero sections the depth of a custom illustration without any image files:
.hero {
background:
radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.15), transparent 50%),
radial-gradient(ellipse at 80% 20%, rgba(236,72,153,0.15), transparent 50%),
linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
min-height: 100vh;
}Button Hover Effects
Gradients can be animated on hover using the background-position trick — size the gradient to 200% and shift its position on hover:
.btn {
background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
background-size: 200% 200%;
background-position: 0% 50%;
transition: background-position 0.4s ease;
}
.btn:hover {
background-position: 100% 50%;
}Card Borders with border-image
The border-image property accepts a gradient, allowing gradient borders without wrapper elements or pseudo-element hacks (for solid backgrounds):
.card-gradient-border {
border: 2px solid transparent;
border-radius: 12px;
background:
linear-gradient(white, white) padding-box,
linear-gradient(135deg, #6366f1, #ec4899) border-box;
}Progress Bars
A gradient progress bar communicates both value and visual energy at once. Pair it with awidth transition for smooth animation:
.progress-bar {
height: 8px;
border-radius: 4px;
background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
width: 73%; /* Controlled by JS or CSS custom property */
transition: width 0.6s ease;
}Gradient Type Comparison
| Gradient Type | CSS Function | Best Use Case | Example |
|---|---|---|---|
| Linear | linear-gradient() | Hero backgrounds, buttons, banners | 135deg, #667eea, #764ba2 |
| Radial | radial-gradient() | Glows, spotlights, ambient light | circle at center, #6366f1, #1e1b4b |
| Conic | conic-gradient() | Pie charts, color wheels, spinners | #6366f1 0deg 120deg, #ec4899 120deg 240deg |
| Repeating Linear | repeating-linear-gradient() | Stripe patterns, ruled lines | -45deg, #fbbf24 0 10px, #1e293b 10px 20px |
Tips for Choosing Good Gradient Colors
The most common mistake when picking gradient colors is jumping straight across the color wheel — for example, blending directly from red to green. Because the midpoint of that transition passes through a muddy brownish-gray, the result looks unattractive even if the endpoint colors are appealing individually.
The fix is to route through a more saturated intermediate hue. Instead of red-to-green directly, try red → orange → yellow-green for a vibrant transition. Alternatively, stay within an adjacent range of hues — the purple-to-pink family, the indigo-to-cyan family — which always produce clean results because the midpoint stays saturated.
A few practical guidelines:
- Keep saturation high at both ends if you want a vivid gradient. Blending a saturated color into an unsaturated one creates an awkward dead zone in the middle.
- Blending different lightness values (light to dark) within the same hue family almost always looks professional and works well in UI backgrounds.
- Add an intermediate color stop at 50% to steer the midpoint hue — this is the single most powerful correction for muddy gradients.
- Limit gradients to two or three stops for most UI work. More than three stops usually looks chaotic unless you are intentionally creating a rainbow or data visualization.
Accessibility: Text on Gradients
Using the SoftStash CSS Gradient Generator
The CSS Gradient Generator gives you a live visual preview as you configure every parameter. Here is how to use it effectively:
- Choose gradient type: Toggle between Linear, Radial, and Conic at the top of the tool.
- Add color stops: Click the gradient bar to add new stops. Drag stops left and right to adjust their positions. Click a stop to open the color picker and change its color and opacity.
- Adjust direction or angle: For linear gradients, drag the angle wheel or type a precise degree value. For radial gradients, set the shape and position.
- Preview in context: The live preview updates instantly. You can see exactly how your gradient will look before copying a single line.
- Copy the CSS: Hit the Copy CSS button to get production-ready CSS for the
backgroundproperty, ready to paste into any stylesheet or framework.
Everything runs in your browser. No gradient definitions are sent anywhere — it is a pure client-side tool. You can use it offline once the page has loaded.
Browser Support
CSS gradients have been supported in all major browsers since 2014, making them safe to use without any polyfills or fallbacks in virtually every production environment. Conic gradients arrived later but are now fully supported in Chrome 69+, Firefox 83+, Safari 12.1+, and Edge 79+ — covering well over 97% of global browser usage as of 2026. The only scenario where you might need a fallback is supporting very old Android WebView versions in enterprise mobile applications.
Build any gradient visually — no code required
Live preview, copy-ready CSS, and full control over stops, angles, and positions. Runs entirely in your browser with no data sent to any server.
Open CSS Gradient Generator →Try the Tools — 100% Free, No Sign-Up
Everything runs in your browser. No uploads. No accounts. No ads.
Explore All Tools →