raatools/

CSS Gradient Generator

Create linear and radial CSS gradients visually and copy the code.

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

Presets

What are CSS gradients?

CSS gradients create smooth, continuous transitions between two or more colors without using images. They are rendered natively by the browser, which means they scale to any resolution, load instantly, and produce zero HTTP requests. Gradients are one of the most powerful tools in modern CSS for creating visually rich backgrounds, buttons, and decorative elements.

There are two main types of CSS gradients: linear gradients that transition along a straight line, and radial gradients that radiate outward from a center point. A third type, conic gradients, sweeps around a central point like a color wheel. This tool focuses on linear and radial gradients, which cover the vast majority of design needs.

CSS gradient syntax

The linear-gradient() function takes a direction (angle or keyword) followed by color stops. The basic syntax is background: linear-gradient(angle, color1 position1, color2 position2). The angle is in degrees โ€” 0deg goes from bottom to top, 90deg from left to right, and 180deg from top to bottom. You can add as many color stops as needed.

Radial gradients use radial-gradient(shape size at position, color1, color2). The shape can be circle or ellipse. The size keywords (closest-side, farthest-corner, etc.) control how far the gradient extends. If omitted, the browser uses defaults that usually look correct.

How to use this tool

Pick your colors using the color pickers, adjust the gradient angle with the slider or by typing a degree value, and add or remove color stops as needed. The tool generates the CSS code in real time. Click the copy button to copy the complete CSS rule to your clipboard, then paste it into your stylesheet.

Design tips for gradients

Subtle gradients look more professional than dramatic ones. A shift of 10โ€“20 degrees in hue between two closely related colors creates an elegant, modern look. Avoid combining more than three colors unless you are intentionally creating a rainbow effect. Large areas benefit from soft gradients, while small UI elements like buttons can handle bolder transitions.

For dark mode designs, gradient overlays on dark backgrounds add depth without being distracting. Use semi-transparent color stops (rgba or hsla) to create glass-like effects. Layer multiple gradients using commas in the background property for complex compositions.

Performance considerations

CSS gradients are GPU-accelerated and extremely performant โ€” far better than loading gradient images. However, very complex gradients with many color stops can cause minor rendering differences between browsers. Always test your gradients in Chrome, Firefox, and Safari. Modern browsers support gradients without vendor prefixes, so -webkit-linear-gradient is no longer necessary.

Frequently asked questions

Can I animate CSS gradients?

CSS cannot animate gradient values directly using transition. However, you can animate the background-position of an oversized gradient, use @property to animate custom properties inside gradients, or crossfade between two gradients using opacity on pseudo-elements.

What is the difference between linear and radial gradients?

A linear gradient transitions colors along a straight line at a specified angle. A radial gradient transitions outward from a center point in a circular or elliptical shape. Choose linear for backgrounds and banners, and radial for spotlight effects or button highlights.