CSS Gradient Generator β€” Linear, Radial & Conic Gradient Builder

Build beautiful CSS gradients visually. Real-time preview and one-click copy.

deg
β Ώ#6366f1%
β Ώ#8b5cf6%
β Ώ#ec4899%
background: -webkit-linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);

CSS Gradient Types Explained

CSS provides three native gradient functions that cover virtually every design use case. linear-gradient() transitions colors along a straight line at any angle β€” the most common type used for button backgrounds, hero sections, and card accents. radial-gradient() radiates colors outward from a focal point in either a circular or elliptical shape, useful for spotlight effects, glows, and radial decorative elements. conic-gradient() sweeps colors around a central point like a pie chart, making it ideal for progress rings, color wheels, and angular decorative patterns.

All three gradient types are defined in the CSS Images specification and are fully supported in all modern browsers. No JavaScript or external libraries are required β€” gradients are pure CSS and render entirely on the GPU, making them highly performant even on mobile devices.

Color Stop Positioning

  • Default spacing β€” If you omit position percentages, the browser spaces stops evenly. Two stops β†’ 0% and 100%. Three stops β†’ 0%, 50%, 100%.
  • Sharp transitions β€” Place two stops at the same position to create a hard edge with no blending: linear-gradient(red 50%, blue 50%) produces a crisp split rather than a blend.
  • Color hints β€” An optional midpoint between two stops (e.g., red, 30%, blue) shifts where the transition midpoint falls, giving you finer control over how quickly one color bleeds into the next.
  • Transparency β€” Use colors with alpha channel (rgba() or 8-digit hex like #ff000080) to create gradients that fade to transparent, useful for overlays and text-shadow effects.

Performance and Best Practices

  • Prefer CSS gradients over images β€” A CSS gradient is a few bytes of text vs. a PNG that could be 50–200KB. For backgrounds and decorative fills, always prefer CSS gradients for performance.
  • Use the -webkit- prefix sparingly β€” Modern browsers (Chrome, Firefox, Safari, Edge) all support unprefixed linear-gradient and radial-gradient. The -webkit- prefix is only needed for Safari versions older than 12.1 (released 2019), which represent a negligible share of traffic for most sites.
  • Avoid overly complex gradients in animations β€” Animating gradient colors with CSS transitions requires the browser to repaint on every frame. For animated gradients, prefer animating background-position on an oversized static gradient instead of animating color values.
  • Test on OLED screens β€” Deep dark gradients (near-black to black) can show banding on some OLED displays due to limited dark color precision. Add a very subtle color shift or use slightly different shades to avoid flat bands.

Frequently Asked Questions

How do I animate a CSS gradient?

CSS cannot directly transition gradient color values, but you can fake it elegantly. The most common technique: set a large background (e.g., 400% width), then animate background-position with a CSS @keyframes animation. Another approach uses pseudo-elements β€” place the new gradient on ::after and animate its opacity from 0 to 1, creating a smooth cross-fade between two gradients.

Can I use gradients on text?

Yes: apply the gradient as background on the text element, then add -webkit-background-clip: text; -webkit-text-fill-color: transparent;. This clips the gradient to the shape of each letter. The -webkit- prefixes are still required for this specific property even in non-WebKit browsers (they all implement the WebKit alias).

What is the difference between circle and ellipse in radial-gradient?

circle constrains the gradient to a perfect circle regardless of the element's aspect ratio. ellipse (the default) stretches to match the element's bounding box β€” so it looks circular only in square elements and stretches in rectangles. For spotlight effects, circle usually looks more natural.

How do I repeat a gradient pattern?

Use repeating-linear-gradient(), repeating-radial-gradient(), or repeating-conic-gradient(). These repeat the stop pattern indefinitely. Example: repeating-linear-gradient(45deg, #000 0px, #000 10px, #fff 10px, #fff 20px) creates a classic diagonal stripe pattern.