How to use the CSS gradient generator
- Pick a preset from the gallery. Filter by mood (warm, cool, pastel, vivid, dark, earthy, neon, monochrome) or by type, then select Customize.
- Choose the gradient type: linear, radial, conic or mesh. Then choose what it applies to: a background, text, or a border.
- Edit the color stops. Drag the handles on the stop bar, or focus one and use the arrow keys (Shift moves 10%; Delete removes it). Click anywhere on the bar to add a stop there, up to 10 in total.
- Set the direction. Drag the angle dial for linear and conic gradients, or drag the center point for radial and conic ones. For mesh gradients, drag each color point on the pad.
- Choose the color mixing. OKLCH gives vivid, even blends. sRGB matches the classic look.
- Add a finish: a grain overlay, rounded corners, or sample text to test readability.
- Review the checks, then copy or download CSS, CSS variables, SCSS, Tailwind classes, an SVG file, or a PNG image in a choice of sizes.
How it works: anatomy of a CSS gradient
A gradient is an image, so it goes in background or background-image:
background: linear-gradient(135deg in oklch, #4F46E5 0%, #DB2777 100%);
- Direction. For linear gradients,
0degpoints up and angles turn clockwise, so90degruns left to right. Radial gradients start at a center point; conic gradients sweep around one. - Color stops are a color plus a position. Two stops at the same position make a hard edge instead of a blend.
- Interpolation method.
in oklchorin oklabblends in a perceptual color space.longer huetakes the long way round the color wheel, which gives rainbow effects from two colors. - Repeating gradients repeat the stop pattern to fill the box, which is handy for stripes and rings.
Browser support and fallbacks
Linear, radial, conic and repeating gradients work in every current browser. Color interpolation methods (in oklch) work in all current major browsers, and the studio always writes an sRGB line first as a fallback. Gradient text uses background-clip: text along with the -webkit- prefix that some browsers still need.
Worked examples
Example 1: a hero background with readable text
Load Midnight · Mesh, set Text over the gradient to white, and type your headline. The contrast check measures the darkest and lightest points of the mesh and confirms the text passes WCAG AA.
Example 2: a gradient heading
Load Electric · Linear, then switch Apply to to Text. The export gives you the background-clip: text rules, with a solid color set first as a fallback.
Example 3: a gradient border card
Load Aurora · Three-stop and set Apply to to Border. The studio uses two background layers, one clipped to the padding box and one to the border box, so the border follows rounded corners exactly without extra elements.
Tips and common mistakes
- Muddy midpoints. Complementary colors such as blue and orange turn grey in sRGB. Switch to OKLCH or add a middle stop.
- Text on busy gradients. Check the weakest contrast point, not the average. A semi-transparent scrim behind the text helps when the gradient has to stay vivid.
- Banding on large areas. Smooth gradients over big dark areas can show steps. A light grain overlay at 10–20% hides banding.
- Too many mesh layers. Each mesh point is a full-size layer. Keep to around five, and don’t animate large mesh backgrounds.
Import CSS from your site
Already have a style you like? Open Import CSS (copy from a site), paste a rule or just its declarations from your stylesheet or your browser’s developer tools, and press Import into the controls. This tool reads the first linear, radial or conic gradient in background or background-image (repeating ones too), with its angle, shape, center and stops, plus border-radius. Everything else, and rules for states such as :hover or media queries, is listed as skipped, and the import can be undone in one step.