CSS Gradient Generator

Build linear and radial CSS gradients visually and copy the CSS code

Try an example
Type
Angle135Β°

Color stops

0%
100%

CSS output

background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);

What Is a CSS Gradient?

A CSS gradient generator is a visual tool that helps you build smooth color transitions without writing gradient syntax by hand. In CSS, a gradient is a smooth transition between two or more colors, rendered directly by the browser without any image file. The CSS Image Module Level 4 specification defines gradient functions as a type of image value, which means they can appear anywhere a background-image, list-style-image, or border-image value is accepted. Because the browser rasterizes gradients at render time, they scale to any resolution and never produce blurry artifacts on high-DPI screens. Using a CSS gradient generator saves time and reduces guesswork β€” you adjust colors and positions visually, then copy the finished CSS rule.

CSS supports three main gradient shapes: linear (along a straight line), radial (outward from a center point), and conic (a sweep around a center point). Each shape accepts a list of color stops, where you specify the color and optionally a position (percentage or length). The browser interpolates colors between stops using the sRGB color space by default, though CSS Color Level 4 allows specifying other color spaces like oklch and lab for perceptually smoother transitions.

Gradients replace image-based backgrounds for most decorative purposes on the web. A single CSS rule produces what once required a Photoshop export and an HTTP request. They are resolution-independent, require zero network bandwidth beyond the CSS itself, and can be animated or transitioned with standard CSS properties. The gradient syntax has been stable across all major browsers since 2013, and the unprefixed form works in Chrome, Firefox, Safari, and Edge without fallbacks.

Why Use This CSS Gradient Generator?

Writing gradient syntax by hand means guessing at stop positions, checking angle values, and repeatedly refreshing to see the result. A visual builder lets you see the gradient as you build it, adjust stops by dragging, and copy the final CSS when it looks right.

⚑
Live Visual Preview
See the gradient update in real time as you change colors, positions, and angles. No need to switch between your editor and browser.
πŸ”’
Privacy-first Processing
All rendering happens in your browser. No color data or gradient configurations are sent to any server.
🎨
Multiple Gradient Types
Build linear and radial gradients with full control over direction, angle, and color stop positions. Copy the CSS with one click.
πŸ“‹
No Account Required
Open the page and start building. No sign-up, no email gate, no rate limits. Works offline once loaded.

CSS Gradient Generator Use Cases

Frontend Development
Build hero section backgrounds, card overlays, and button hover states. Preview the gradient at the target dimensions, then paste the CSS directly into your stylesheet or Tailwind config.
Email Template Design
Some email clients support CSS gradients in inline styles. Generate the exact gradient code and inline it on the element, with a solid fallback color for clients that do not render gradients.
Design Prototyping
When iterating on color schemes in the browser instead of Figma, generate gradient backgrounds quickly. Compare multiple options side by side without exporting assets.
DevOps Dashboard Styling
Status dashboards and monitoring UIs use color gradients to represent severity ranges (green to red) or data density. Generate the gradient values and apply them to chart backgrounds or status bars.
Data Visualization
Chart libraries like D3.js and Recharts accept CSS gradient definitions for area fills and heatmaps. Build the gradient visually, then extract the stop colors for your scale function.
Learning CSS
Students studying CSS can experiment with gradient syntax, see how angle changes affect direction, and understand color stop positioning. The generated CSS is a working reference.

CSS Gradient Types Reference

CSS defines five gradient functions. The three primary types (linear, radial, conic) each have a repeating variant that tiles the pattern. repeating-linear-gradient() and repeating-radial-gradient() are useful for striped backgrounds and concentric rings. All gradient functions accept color stops in any CSS color format: HEX, RGB, HSL, named colors, or oklch. Browser support for all five functions is effectively universal across Chrome, Firefox, Safari, and Edge β€” no vendor prefixes are required.

FunctionExample syntaxDirectionCommon use
linear-gradient()to right, #f00, #00fStraight lineBackgrounds, hero sections, progress bars
radial-gradient()circle, #f00, #00fOutward from centerSpotlight effects, buttons, badges
conic-gradient()from 0deg, #f00, #00fSweep around centerPie charts, color wheels, spinners
repeating-linearto right, #f00 0 10px, #00f 10px 20pxTiled lineStripes, progress indicators, decorative borders
repeating-radialcircle, #f00 0 10px, #00f 10px 20pxTiled circleConcentric ring patterns, retro textures

Linear vs Radial vs Conic Gradients

Each gradient type maps colors to geometry differently. Choosing the right type depends on the visual effect you need, not on a quality difference between them. For most page backgrounds and section dividers, a linear gradient is the correct default β€” it is the simplest to reason about and the most predictable across elements of varying sizes. Radial and conic gradients are better reserved for specific visual effects where the circular or rotational geometry is meaningful rather than decorative.

linear-gradient()
Colors transition along a straight line defined by an angle (0deg = bottom to top, 90deg = left to right) or a keyword like 'to right'. The most common type, used for backgrounds, overlays, and progress indicators. Supports multiple color stops at arbitrary positions.
radial-gradient()
Colors radiate outward from a center point in a circle or ellipse. Control the shape, size, and center position with the syntax. Useful for spotlight effects, vignettes, and circular UI elements like badges or avatar rings.
conic-gradient()
Colors sweep around a center point like the hands of a clock. The starting angle is configurable with 'from Xdeg'. Useful for pie chart segments, color wheels, and rotational loading indicators. Requires at least two stops; repeating the first color at the end creates a seamless loop.

Code Examples

Examples of generating and applying CSS gradients programmatically in JavaScript, Python, CSS, and Go. Each produces valid CSS gradient strings you can use directly in stylesheets or inline styles.

JavaScript
// Generate a CSS linear-gradient string from an array of stops
function buildGradient(angle, stops) {
  const parts = stops.map(s => `${s.color} ${s.position}%`)
  return `linear-gradient(${angle}deg, ${parts.join(', ')})`
}

const stops = [
  { color: '#6366f1', position: 0 },
  { color: '#ec4899', position: 50 },
  { color: '#f59e0b', position: 100 },
]
buildGradient(90, stops)
// -> "linear-gradient(90deg, #6366f1 0%, #ec4899 50%, #f59e0b 100%)"

// Apply to an element
document.querySelector('.hero').style.background = buildGradient(135, stops)
Python
# Generate a CSS gradient string for use in templates or SVGs
def build_gradient(angle: int, stops: list[tuple[str, int]]) -> str:
    parts = [f"{color} {pos}%" for color, pos in stops]
    return f"linear-gradient({angle}deg, {', '.join(parts)})"

stops = [("#6366f1", 0), ("#ec4899", 50), ("#f59e0b", 100)]
print(build_gradient(135, stops))
# -> "linear-gradient(135deg, #6366f1 0%, #ec4899 50%, #f59e0b 100%)"

# Interpolate N colors between two endpoints
def interpolate_hex(c1: str, c2: str, steps: int) -> list[str]:
    r1, g1, b1 = int(c1[1:3], 16), int(c1[3:5], 16), int(c1[5:7], 16)
    r2, g2, b2 = int(c2[1:3], 16), int(c2[3:5], 16), int(c2[5:7], 16)
    return [
        f"#{int(r1+(r2-r1)*i/(steps-1)):02x}"
        f"{int(g1+(g2-g1)*i/(steps-1)):02x}"
        f"{int(b1+(b2-b1)*i/(steps-1)):02x}"
        for i in range(steps)
    ]

interpolate_hex("#6366f1", "#f59e0b", 4)
# -> ['#6366f1', '#9a7399', '#d18042', '#f59e0b']
CSS
/* Linear gradient β€” left to right */
.hero {
  background: linear-gradient(90deg, #6366f1 0%, #ec4899 50%, #f59e0b 100%);
}

/* Radial gradient β€” circular spotlight */
.badge {
  background: radial-gradient(circle at 30% 30%, #6366f1, #312e81);
}

/* Conic gradient β€” color wheel */
.wheel {
  background: conic-gradient(from 0deg, #ef4444, #f59e0b, #22c55e, #3b82f6, #8b5cf6, #ef4444);
  border-radius: 50%;
}

/* Multi-stop with transparency */
.overlay {
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.6) 60%,
    rgba(0, 0, 0, 0.9) 100%
  );
}

/* Repeating stripes */
.stripes {
  background: repeating-linear-gradient(
    45deg,
    #6366f1 0 10px,
    transparent 10px 20px
  );
}
Go
package main

import "fmt"

// Stop represents one color stop in a gradient.
type Stop struct {
	Color    string
	Position int // percent 0-100
}

func buildGradient(angle int, stops []Stop) string {
	result := fmt.Sprintf("linear-gradient(%ddeg", angle)
	for _, s := range stops {
		result += fmt.Sprintf(", %s %d%%", s.Color, s.Position)
	}
	return result + ")"
}

func main() {
	stops := []Stop{
		{"#6366f1", 0},
		{"#ec4899", 50},
		{"#f59e0b", 100},
	}
	fmt.Println(buildGradient(135, stops))
	// -> "linear-gradient(135deg, #6366f1 0%, #ec4899 50%, #f59e0b 100%)"
}

Frequently Asked Questions

What is the difference between linear-gradient and radial-gradient?
linear-gradient() transitions colors along a straight line at a given angle, while radial-gradient() transitions colors outward from a center point in a circle or ellipse. Linear gradients are the standard choice for page backgrounds and overlays. Radial gradients work better for spotlight effects and circular UI elements.
How do I set the direction of a linear gradient?
Use an angle in degrees (e.g., 90deg for left-to-right, 180deg for top-to-bottom) or a keyword (to right, to bottom left). The angle rotates clockwise from the bottom: 0deg points upward, 90deg points right. You can also use 'to top right' to target a corner, and the browser calculates the exact angle based on the element's aspect ratio.
Can I animate a CSS gradient?
Browsers cannot interpolate between two gradient values directly with CSS transitions. The common workarounds are: animating the background-position of an oversized gradient, using @property to animate individual color stop values as custom properties, or cross-fading with opacity on a pseudo-element. The @property approach (supported in Chrome and Edge since 2020, Firefox since 2024) is the cleanest solution.
How many color stops can a gradient have?
The CSS specification does not set a maximum. Browsers handle gradients with dozens of stops without performance issues. In practice, most gradients use 2 to 5 stops. Each stop can specify a color and an optional position as a percentage or length value. You can also define two positions per stop to create a hard color band with no transition.
What is the difference between a gradient and an image?
In CSS, a gradient is a computed image. It shares the same rendering pipeline as url() images and can be used anywhere an image value is valid: background-image, list-style-image, border-image, and mask-image. The difference is that a gradient is generated by the browser at render time, scales to any size without quality loss, and adds zero bytes to your page weight since no file is downloaded.
How do I create a gradient with a hard color stop (no transition)?
Place two color stops at the same position. For example, linear-gradient(to right, #6366f1 50%, #ec4899 50%) creates a sharp split with no blending between the colors. You can also use the two-position syntax: linear-gradient(to right, #6366f1 0% 50%, #ec4899 50% 100%) to define each band explicitly.
Is the conic-gradient function supported in all browsers?
conic-gradient() is supported in Chrome 69+, Firefox 83+, Safari 12.1+, and Edge 79+. As of 2024, global browser support exceeds 95% according to Can I Use data. No vendor prefix is needed. For the small percentage of users on older browsers, set a solid background-color as a fallback before the gradient declaration.