CSS Gradient Generator
Design linear, radial and conic gradients with a live preview, then copy the CSS. Up to eight color stops, smooth OKLab and OKLCH blending, presets and a randomizer.
What this generator does
It builds CSS gradients visually and gives you code to paste straight into your stylesheet. Choose linear, radial or conic, add up to eight color stops, drag them into place and watch the preview update. Start from a preset, reverse the colors or try a random combination for ideas.
The three gradient types
| Type | How it flows | Good for |
|---|---|---|
| Linear | Along a straight line set by the angle. 0° runs bottom to top, 90° left to right, 180° top to bottom. | Page and button backgrounds, hero sections |
| Radial | Outward from a center point as a circle or ellipse. | Spotlights, glows, vignettes |
| Conic | Around a center point like a color wheel, starting at the chosen angle. | Pie charts, color wheels, shiny metallic effects |
Tips for gradients that look good
Pick colors that are close in hue or lightness, since gradients between very different colors can turn muddy in the middle. The color blending option fixes much of this: OKLab keeps the middle bright and even, and OKLCH travels around the color wheel for more vivid results. Both work in current versions of Chrome, Edge, Firefox and Safari, and older browsers fall back to the plain color line included in the code. Put text on gradients only after checking its contrast with the Color Contrast Checker.
Using the code
Paste the two lines into any CSS rule, for example .hero { ... }. The first line is a fallback color and the second is the gradient. Gradients are drawn by the browser, so they cost no download and stay sharp at every size. For repeating stripes, tick Repeating pattern, which squeezes the stops into the first fifth so the pattern tiles. The image you share when linking to your page can be set up with the Open Graph Generator.
Frequently asked
How do I use the generated CSS?
Copy it and paste it into a CSS rule for the element you want, such as a section or button. The first line sets a fallback color and the second applies the gradient as a background image.
What does the angle mean?
For linear gradients, 0 degrees points up, 90 points right, 180 points down and 270 points left. For conic gradients the angle sets where the color sweep starts.
Why does my gradient look muddy in the middle?
In standard RGB blending, colors that are far apart in hue pass through a dull gray. Choose OKLab or OKLCH under color blending, or add an extra stop with a brighter middle color.
Do all browsers support OKLab and OKLCH blending?
Current versions of Chrome, Edge, Firefox and Safari do. Very old browsers ignore the whole gradient line, which is why a fallback color is included first.
How many color stops can I use?
From 2 up to 8 in this tool. CSS itself allows many more, and you can edit the copied code by hand to add them.
Can I use a gradient as text color or a border?
Yes, with a few extra lines of CSS, such as background-clip: text for text or border-image for borders. The generated gradient value works in both.