What Is a CSS Gradient?
A CSS gradient is a smooth transition between two or more colours, drawn by the browser itself rather than loaded as an image file. Because gradients are generated in code, they're resolution-independent (sharp on any screen), tiny (a few bytes instead of a large image) and easy to change. They're used for hero sections, buttons, cards, backgrounds, text effects, progress bars, charts and overlays that make text readable on photos.
CSS has three kinds of gradient. Linear gradients blend along a straight line at any angle. Radial gradients spread out from a centre point in a circle or ellipse. Conic gradients sweep around a centre point like a colour wheel or pie chart. Each has a repeating version for stripes and patterns. This free CSS gradient generator lets you design all of them visually.
How to Use the Gradient Generator
- Choose the type: linear, radial or conic.
- Edit the colour stops. Pick colours, type any colour code, set positions, or drag the handles along the bar. Add as many stops as you like.
- Set the angle (linear), shape and position (radial) or start angle (conic).
- Try smooth interpolation. OKLCH avoids the grey, muddy middle you often get between complementary colours.
- Copy the CSS and paste it into your stylesheet. A solid fallback colour is included.
CSS Gradient Syntax
| Type | Example |
|---|---|
| Linear | linear-gradient(90deg, #6366F1 0%, #EC4899 100%) |
| Radial | radial-gradient(circle at center, #fff 0%, #312E81 100%) |
| Conic | conic-gradient(from 0deg at center, red, yellow, lime, cyan, blue, magenta, red) |
| Repeating | repeating-linear-gradient(45deg, #000 0%, #000 5%, #fff 5%, #fff 10%) |
| With interpolation | linear-gradient(in oklch 90deg, blue, yellow) |
For linear gradients, 0deg points up (to top), 90deg points right, 180deg down and 270deg left. You can also use keywords like to right or to bottom right. Colour stop positions are optional: without them, colours are spaced evenly.
Smooth Gradients with OKLCH
By default, browsers blend gradient colours in sRGB, which can produce a dull, greyish band in the middle. Blue to yellow, for example, passes through a muddy grey. CSS Color Level 4 lets you choose the interpolation colour space. in oklch keeps the colours vivid through the transition by moving around the hue wheel, and in oklab gives perceptually even blending without the grey dip. Both are supported in all current browsers (Chrome, Edge, Safari and Firefox). Older browsers ignore the whole declaration, which is why the generated code includes a solid colour first as a fallback.
Gradient Design Tips
- Analogous colours (neighbours on the wheel) make the smoothest, most natural gradients.
- Subtle is professional: a 10–20° hue shift or a light-to-slightly-darker version of one colour looks polished.
- Hard stops (two stops at the same position) create sharp stripes and flags, such as
#000 50%, #fff 50%. - Text over gradients must still pass contrast checks at both ends. Test the lightest and darkest colours with the contrast checker.
- Gradient text: combine with
background-clip: textandcolor: transparent. - Layer gradients by separating several with commas in one
backgrounddeclaration.
Features
- Three typesLinear, radial and conic, plus repeating.
- Draggable stopsUnlimited colours, keyboard accessible.
- OKLCH / OKLabVivid, modern colour interpolation.
- Presets and randomInstant inspiration.
- Any colour formatIncluding transparency (rgba).
- Clean CSSWith a solid fallback, ready to paste.
Using Gradients as Overlays on Images
A popular technique is to layer a semi-transparent gradient over a photo so headings stay readable: background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.65) 100%), url(photo.jpg) center / cover;. The gradient darkens the bottom of the image where the text sits, while the top stays bright. Enter rgba colours in the stop fields above to build the overlay, then add your image URL after a comma in your own CSS. The same approach creates coloured duotone washes and vignette effects.
Frequently Asked Questions
Do I still need -webkit- prefixes for gradients?
No. Unprefixed gradients have worked in every browser for more than a decade.
How do I make a transparent gradient?
Use a stop with transparency, such as rgba(0,0,0,0) or #00000000. The tool accepts rgba values in the stop fields.
Can I animate a CSS gradient?
Not directly, but you can animate background-position on an oversized gradient, or animate registered @property colour variables.
What angle is "to right"?
90deg. "to bottom" is 180deg (the default), "to left" is 270deg and "to top" is 0deg.
How do I apply a gradient to text?
Set the gradient as background, then add background-clip: text; -webkit-background-clip: text; color: transparent.