CSS Gradient Generator

Visually design linear, radial, and conic gradients and instantly get the CSS code. Includes presets and a random color generator.

Color stops
Color HEX Position % Opacity % Delete

You need at least two color stops. Position order is automatically sorted and applied to the CSS.

Presets

What is the CSS Gradient Generator?

CSS gradients create smooth color transitions for backgrounds without using image files. They're just a line of code, so they're fast, resolution-independent, and easy to edit. This tool lets you build them visually. Choose between `↗ Linear`, `◎ Radial`, and `🌀 Conic` types, then adjust angles, positions, and an unlimited number of color stops. Every change appears instantly in the preview. When you're done, just copy the generated CSS. If you need inspiration, try one of the built-in presets like 'Instagram' or 'Aurora', or click `🎲 Randomize` for new ideas. It's free, and everything runs in your browser—nothing is sent to a server.

How to use

  1. Select a gradient type: `↗ Linear` for banners, `◎ Radial` for a spotlight effect, or `🌀 Conic` for pie charts and rings.
  2. In the "Color stops" table, pick colors and adjust their "Position %" and "Opacity %". Use the `+ Add stop` button to add more colors to your gradient.
  3. Fine-tune the appearance. For linear gradients, drag the "Angle" slider. For radial or conic, adjust the "Shape" and "Center position".
  4. Copy the complete rule from the "CSS code" box and paste it into your stylesheet. You can also start by clicking a preset or `🎲 Randomize`.

CSS Gradient Generator guide

How this tool is used in real work, and what to watch out for.

Why Does My Gradient Look Muddy in the Middle?

It's common for the transition between two colors to produce a dirty, grayish tone. A gradient from blue to orange will look muddy in the middle. This isn't a matter of taste; it's a result of how far apart the two colors are on the color wheel.

By default, CSS gradients create a straight line between two colors in RGB space. If you connect colors on opposite sides of the color wheel (complementary colors), that line passes directly through the desaturated gray center. That's what makes the transition look muddy.

  • Connect colors that are close on the color wheel, within about 30-60 degrees of each other. Think blue to purple, or orange to pink. This tool's "🎲 Randomize" button uses this exact method to pick colors.
  • If you must use complementary colors, add an intermediate color stop to create a path through a brighter color. Going around the color wheel—like from blue → teal → yellow—avoids the muddy center.
  • Varying the lightness (brightness) of the colors also makes the gradient feel much more natural. Two colors with the same brightness can look blurred and indistinct where they meet.
  • Pairing two highly saturated colors can sometimes create an artificial color band at the transition. Lowering the saturation slightly will usually fix this.
The "🎲 Randomize" button picks colors from an analogous color scheme and gives them slightly offset brightness levels. This is because nine times out of ten, truly random RGB values produce a dull, muddy result. The fastest way to a good gradient is to click it until you find a decent starting point, then fine-tune the colors yourself.

Linear, Radial, Conic: When to Use Which

For conic gradients, you can set a starting angle. When you select "🌀 Conic" in this tool, the angle slider controls the `from Xdeg` value. An angle of 0deg starts at the top (12 o'clock) and proceeds clockwise.

For radial gradients, the angle is irrelevant, so the slider is hidden. Instead, you can select the `Shape` (Circle/Ellipse) and the `Center position`. Setting the center to "Top" can create the effect of light shining down from above.

TypeHow it SpreadsCommon Uses
↗ LinearIn a straight line at a set angle.Banner backgrounds, buttons, headers, cards. This is what you'll use most of the time.
◎ RadialOutward from a central point.Spotlight effects, drawing focus, darkening screen edges (vignetting).
🌀 ConicRotates around a central axis.Pie charts, color wheels, circular loading indicators, rainbow rings.
The angle for a `linear-gradient` can be counter-intuitive. `0deg` creates a gradient that goes from bottom to top, and `90deg` goes from left to right. The angle increases clockwise, so `180deg` is top to bottom. A common diagonal gradient is `135deg`.

Creating Overlays for Text on Images

In practice, one of the most common uses for gradients isn't for creating pretty backgrounds, but for ensuring text on top of a photo is readable. If you place white text over a hero image, it will disappear into any bright parts of the photo. But darkening the entire image makes it look dull.

The solution is a transparency gradient that darkens only the area behind the text. By setting one color stop to zero opacity, that part of the image remains fully visible, while the other end fades smoothly to a darker shade.

  1. Set both color stops to black (#000000).
  2. Set the first stop's opacity to 0 and its position to around 40%.
  3. Set the second stop's opacity to 70-80% and its position to 100%.
  4. Set the angle to 180deg (top to bottom) and copy the CSS.
css
.hero {
  position: relative;
  background: url(photo.jpg) center/cover;
}
/* Darken only the bottom — for when text is at the bottom */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(0, 0, 0, 0) 40%,
    rgba(0, 0, 0, 0.75) 100%);
}
.hero h1 { position: relative; z-index: 1; color: #fff; }
Make sure the color of the 0% opacity stop is the same as the color of the other stop. A gradient from transparent white to opaque black will look milky in the middle, because even an invisible color still participates in the interpolation process. Since this tool lets you control color and opacity separately, just set both stops to the same color and adjust the opacity from 0 to 80.

Making Stripes with Repeating Gradients

It's common to enable the "Repeating" option and feel like nothing happened. The `repeating-` prefix works by restarting the gradient from the beginning as soon as it ends. If your color stops are spread out across the full 0% to 100% range, the gradient fills the container exactly once, leaving no space to repeat.

To create stripes, you must define your color stops within a narrow range. And by placing two different colors at the same position (e.g., both at 50%), you can create a hard, sharp line with no gradation.

css
/* Diagonal stripes — placing stops at the same position creates a hard edge */
background: repeating-linear-gradient(45deg,
  #4f46e5 0px, #4f46e5 10px,
  #c7d2fe 10px, #c7d2fe 20px);
This tool will warn you if you enable repeating while your stops are spread across more than 60% of the range, as the effect will be invisible. Try clicking the "Diagonal Stripes" preset to see how its stops are arranged. This tool only uses percentages for position, but for precise pixel-based stripes, you can copy the code and change the `%` units to `px`.

Practical Considerations

  • Text Contrast — Text on a gradient background can easily become unreadable on the lighter end. Always check contrast against your lightest color stop.
  • Color Banding — Large, smooth gradients can sometimes display visible bands of color, especially between dark shades. Adding another color stop or overlaying a very subtle noise texture can help mitigate this.
  • Button Hover States — Gradients cannot be smoothly animated with CSS `transition`. The color will change abruptly on hover.
  • Dark Mode — A bright gradient can be jarring in dark mode. Prepare a separate, desaturated, and darker version for dark-mode users.
Using the `background` property for a gradient will overwrite the element's `background-color`. If your CSS is slow to load or the gradient declaration has a typo, the background may appear empty. It's safer to declare a fallback `background-color` first, then specify the `background` with the gradient.

Frequently asked questions

How do I make stripes with the `Repeating` option?

Check "Repeating" and set your color stops very close together, like at 5% and 10%. This small segment will then repeat across the entire element, creating a stripe or pattern effect.

What direction does the `Angle` control point to?

For linear gradients, CSS angles start from the bottom. `0deg` is bottom-to-top, `90deg` is left-to-right, and `180deg` is top-to-bottom. A common top-left to bottom-right diagonal is `135deg`.

What's a good use for opacity in a gradient?

Setting a color stop's "Opacity %" to 0 creates a fade-to-transparent effect. This is great for image overlays that darken part of a photo, making text on top of it easier to read.

Are the gradients I design sent to your server?

No. This tool runs entirely in your web browser. All calculations and code generation happen on your computer, and none of your data is sent to or stored on our servers.