CSS Gradient Generator

Color Stops (2/8)

0%
100%

Preset Gradients

CSS

background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

Gradient Value

linear-gradient(135deg, #667eea 0%, #764ba2 100%)

Stop Colors

#667EEA0%
#764BA2100%

Tailwind CSS

Two-stop linear gradients can use Tailwind's built-in gradient utilities:

bg-gradient-to-b from-[#667eea] to-[#764ba2]

Type

linear

Stops

2

Angle

135°

How to Use This Tool

  1. 1.Choose a gradient type — Linear draws along a straight line, Radial radiates from a center point, and Conic sweeps around a center like a pie chart
  2. 2.Click any color stop's color swatch to open the color picker, or type a hex code directly. Drag the position slider to control where along the gradient each color appears
  3. 3.For linear and conic gradients, adjust the angle slider or type a degree value (0-360°). For radial gradients, switch between ellipse and circle shapes
  4. 4.Add up to 8 color stops with the "+ Add Stop" button, or remove stops with the × button (minimum 2 required)
  5. 5.Copy the CSS code from the output panel and paste it into your stylesheet. Try a preset gradient for quick inspiration

Rate this tool

Linear vs Radial vs Conic: Picking the Right CSS Gradient for the Job

A CSS gradient generator saves you from memorizing the exact syntax of linear-gradient(), radial-gradient(), and conic-gradient()— three functions that look deceptively similar but behave in fundamentally different ways. You're mocking up a hero section and want a diagonal purple-to-indigo wash. Or you need a soft spotlight behind a pricing card. Or maybe a pie-chart-style sweep for a loading indicator. Each of those calls for a different gradient function, with different parameters, and getting one wrong means starting over. This guide breaks down exactly what each function does, how the browser renders it pixel by pixel, and when to reach for one over another.

Three CSS gradient types compared side by side: a diagonal linear gradient, a circular radial gradient, and a conic sweep gradient with labeled syntax

Three Gradient Functions, Three Different Jobs

CSS has exactly three gradient functions. linear-gradient() draws color along a straight line — an angle you pick. radial-gradient() radiates outward from a center point in an ellipse or circle. conic-gradient() sweeps around a center like the hand of a clock. Each produces an <image>value in the CSS spec, which means they work anywhere you'd put a URL — background-image, border-image, even list-style-image.

All three share the concept of color stops: pairs of a color and a position along the gradient line. The browser interpolates in the sRGB color space between adjacent stops, producing smooth transitions at 60+ fps during animations. But the "gradient line" itself is shaped differently for each function — that's the part most developers get wrong on first attempt.

Anatomy of a linear-gradient() Declaration

A linear gradient starts from a line running through the center of the element at the angle you specify. The default angle, 180deg, draws from top to bottom. 90deg goes left to right. 0deg goes bottom to top. A two-stop gradient like linear-gradient(135deg, #667eea 0%, #764ba2 100%) starts purple-blue in the top-left corner and ends deep purple at the bottom-right.

Here's the part that trips people up: the gradient line isn't the width of the element — it's the diagonal at the specified angle. For a 400×200px element at 45deg, the gradient line is approximately 447px long (√(400² + 200²)). The spec calculates the exact length so that the first and last color stops always reach the corners. This means the same angle on different aspect ratios produces slightly different visual results. The keyword to bottom right avoids this by always pointing at the exact corner regardless of element dimensions.

Need a hard stripe instead of a smooth blend? Set two adjacent stops to the same position: linear-gradient(90deg, red 50%, blue 50%) splits the element cleanly in half with no transition zone. This technique powers progress bars, flag patterns, and striped backgrounds without a single image file.

Radial Gradients: Circles, Ellipses, and Sizing Keywords

A radial gradient starts at a center point and expands outward. The default shape is an ellipse that matches the element's aspect ratio — on a 400×200px box, the ellipse is twice as wide as it is tall. Switch to circle for a perfectly round gradient regardless of the element shape.

Four sizing keywords control how far the gradient extends: closest-side, farthest-side, closest-corner, and farthest-corner (the default). On a 400×200px element centered at 50% 50%, farthest-corner draws the final stop at the corner — roughly 224px from center. closest-side stops at just 100px (the nearest edge). That's a 2.24× difference in gradient size from the same color stops.

Position the center with at: radial-gradient(circle at 20% 80%, #f12711, #f5af19) places the glow near the bottom-left. Designers use off-center radial gradients for spotlight effects behind UI elements — a subtle technique that adds depth without shadows.

The 360° Sweep: How conic-gradient Differs

Where linear gradients run along a line and radial gradients expand from a point, conic gradients rotate around one. Think of it as a color pie: the browser draws color around a 360° arc starting from the top (12 o'clock position) by default. conic-gradient(red, yellow, lime, aqua, blue, magenta, red) produces a full color wheel — the same one you'd see inside a hex to RGB converter's hue picker.

The from keyword rotates the starting angle: conic-gradient(from 90deg, ...)begins at the 3 o'clock position instead of 12. Combined with at for positioning, you can build pie charts entirely in CSS — no SVG or canvas needed. A two-slice chart showing 73% progress: conic-gradient(#2563EB 0% 73%, #E5E7EB 73% 100%). That single line replaces a dozen lines of SVG markup.

Conic gradients arrived in browsers later than linear and radial — Chrome 69 (2018), Firefox 83 (2020), Safari 12.1 (2019). For projects still supporting pre-2018 browsers, add a solid background-color fallback before the gradient declaration.

Color Stop Positions and Hard Lines

Every color stop has an optional position value — a percentage, a length (px, em, rem), or nothing at all. When you omit positions, the browser distributes stops evenly. Three stops without positions land at 0%, 50%, and 100%. Five stops: 0%, 25%, 50%, 75%, 100%.

Explicit positions give you fine-grained control. A gradient like linear-gradient(90deg, #0f0c29 0%, #302b63 30%, #24243e 100%) compresses the first transition into the left 30% of the element while the second transition spans the remaining 70%. This asymmetry creates more visual interest than evenly spaced stops — a trick professional designers rely on.

Two stops at the same position create a hard line with zero blending: linear-gradient(90deg, red 40%, blue 40%). This is the CSS gradient equivalent of a border — except it works at any angle. Stack multiple hard-line pairs for stripes: repeating-linear-gradient(45deg, transparent, transparent 10px, #ccc 10px, #ccc 20px) produces a 45° candy-stripe pattern repeating every 20px. The browser tiles this infinitely across the element at virtually zero performance cost.

Which Gradient Type Fits Your Design?

Use CaseBest TypeWhy
Hero section backgroundLinear (135°)Diagonal wash looks dynamic without competing with text
Button hover glowRadial (circle)Centered spotlight follows the user's focus
Progress indicatorConicSweep angle maps directly to percentage (73% = 262.8°)
Card depth/vignetteRadial (ellipse)Ellipse adapts to container aspect ratio automatically
Diagonal stripe patternRepeating linearHard stops + repeating-linear-gradient tile infinitely
Color picker hue ringConic360° hue sweep matches the HSL color model natively

The rule of thumb: if the color transition has a direction, use linear. If it has a focal point, use radial. If it has an arc, use conic. When you're unsure, start with a linear at 135° — it works well with left-aligned content because the darker tone frames the text while the lighter side provides breathing room.

Rendering Cost, Banding, and Fallbacks

CSS gradients are rendered by the browser's compositor on the GPU. A static gradient costs almost nothing — comparable to rendering a solid color. The browser calculates each pixel's color mathematically rather than decoding an image file, so there's no network request and no memory overhead from bitmap storage. For a 1920×1080 hero with a two-stop linear gradient, the computation is roughly 2 million multiply-adds — finished in under 1ms on any GPU from the last decade.

Banding — visible steps between colors instead of a smooth transition — appears when the color difference between stops is large and the element covers many pixels. An 8-bit display shows 256 levels per channel. A gradient from #000000 to #FFFFFFacross 1920px means each shade covers about 7.5 pixels. That's usually fine. But a gradient from #0a0a0a to #1a1a1a across the same width spreads only 16 levels over 1920px — 120px per shade, clearly visible as bands. The fix: widen the color range, add an intermediate stop, or apply a subtle noise texture overlay.

Always declare a background-color before your gradient. If the gradient syntax fails (old browser, typo), the solid color acts as a fallback. This costs zero bytes when the gradient renders normally.

Layering Multiple Gradients on One Element

CSS background-image accepts a comma-separated list of values, drawn back to front. The first gradient is on top. This lets you combine effects: background-image: linear-gradient(to bottom, rgba(0,0,0,0.3), transparent), radial-gradient(circle at 30% 70%, #667eea, #764ba2) puts a dark-to-transparent veil over a purple radial glow — a depth technique often seen on SaaS landing pages.

You can stack up to the browser's practical limit (no spec cap, but 5-10 layers is common). Each layer can have its own background-size and background-position, enabling complex patterns from pure CSS. A checkerboard, for instance, requires just two 45° linear gradients at offset positions — no image file, no SVG.

For design systems, define gradient tokens as CSS custom properties: --gradient-primary: linear-gradient(135deg, var(--blue-500), var(--purple-600)). Every component that references the token stays consistent, and changing the brand gradient is a one-line edit. If you're building with Tailwind, check our RGB to hex converter to translate design tool colors into the hex values Tailwind's arbitrary value syntax expects.

Marko Sinko
Marko SinkoTechnical Tools Editor

Croatian developer with a Computer Science degree from University of Zagreb and expertise in advanced algorithms. Marko builds and verifies the technical tools, number system converters, and scientific calculators across UnitCalcTools, ensuring mathematical precision and developer-friendly interfaces.

Last updated: April 13, 2026LinkedIn

Frequently Asked Questions

Use the direction keyword 'to bottom right' inside linear-gradient: background: linear-gradient(to bottom right, #FF6B6B, #4ECDC4). This draws color from the top-left corner toward the bottom-right. Numerically, this equals roughly 135deg on a square element, but the keyword version automatically adjusts for non-square aspect ratios so the gradient always hits the exact corners.
A linear-gradient transitions colors along a straight line at a specified angle (0deg goes bottom-to-top, 90deg goes left-to-right). A radial-gradient radiates colors outward from a center point in an elliptical or circular shape. Linear gradients suit backgrounds and section dividers, while radial gradients work better for spotlight effects, glowing buttons, and vignettes.
Yes, CSS gradients support unlimited color stops. Each stop can have an explicit position like linear-gradient(90deg, red 0%, yellow 25%, green 50%, blue 100%). Browsers interpolate smoothly between adjacent stops. Three to five stops handle most designs; beyond that, performance stays fine but the gradient becomes harder to maintain manually, which is where a visual generator helps.
Banding appears when the color difference between stops is too large and the element spans many pixels, exceeding the 8-bit-per-channel color depth of standard displays. Fixing it: add a slight intermediate stop at the midpoint to break the transition into smaller steps, or inject 1-2% noise with a tiny background-image overlay. Gradients between similar hues (like blue-500 to blue-700) almost never show banding because the per-pixel color delta stays below 1 out of 256.
Use: background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red). Starting at the top (0deg by default), each named color occupies an equal slice of the 360-degree sweep, and the final 'red' connects back to the start for a seamless loop. Add 'from 90deg' after the opening parenthesis to rotate the wheel so red starts on the right instead of the top.
Linear-gradient and radial-gradient have full support in every modern browser since 2013 (Chrome 26, Firefox 16, Safari 6.1, Edge 12). Conic-gradient arrived later but reached full support by 2020 (Chrome 69, Firefox 83, Safari 12.1). The only exception is Internet Explorer, which never supported any gradient function. The old -webkit-linear-gradient vendor prefix is no longer needed for any current browser.
A color stop position tells the browser where along the gradient line a color should be fully rendered, expressed as a percentage or length. In linear-gradient(90deg, red 0%, blue 100%), red starts at the left edge and blue ends at the right. Moving blue to 50% compresses the transition into the first half and fills the remaining space with solid blue. Two stops at the same position (red 50%, blue 50%) create a hard line with no blending.
Use rgba() or hsla() color values, or the 8-digit hex format. For example, linear-gradient(to right, rgba(255,0,0,1), rgba(255,0,0,0)) fades red from fully opaque to fully transparent. You can also use the CSS keyword 'transparent' as a stop, which equals rgba(0,0,0,0) — note this fades through black midway, so rgba with your actual color and alpha 0 produces a cleaner fade.

Related Tools