A gradient is often the quickest way to make a flat section feel finished: a hero banner, a button hover state, a card background. Writing the CSS by hand means guessing angles and percentages, then reloading to check. Here you see the result as you move each slider, and the code is always ready to copy.
Three kinds of gradient
- Linear runs in a straight line. 90° goes left to right, 180° top to bottom, 135° from the top-left corner.
- Radial spreads out from a centre point as a circle or ellipse. Use it for spotlights and soft glows.
- Conic sweeps around a point. A conic gradient of seven hues makes a colour wheel; two stops at the same position make a pie slice.
Better colour blending
Older gradients mix colours in sRGB, the same maths screens have used for decades. It is predictable, but mixing two saturated colours often gives a dull, greyish middle. Modern CSS lets you blend in OKLab or OKLCH instead. These spaces are built around how people perceive colour, so a blue-to-yellow gradient stays vivid all the way across. Try switching the blending option on the Sunset preset to see the difference.
Tips for production
- Keep text readable: test your heading colour against the lightest and darkest part of the gradient.
- Fewer stops usually look more polished. Two or three colours cover most designs.
- For banding on large, subtle gradients, add a third stop close to the middle colour, or a very light noise texture.
- Everything runs in your browser. Nothing you design here is sent anywhere.
How to use the CSS Gradient Generator
- Choose Linear, Radial or Conic at the top.
- Set the angle, or the shape and centre for radial and conic gradients.
- Edit each colour stop: pick a colour, type any CSS colour, or drag its position slider.
- Use + Add colour, Reverse or Random, or start from a preset.
- Click Copy CSS and paste the
backgroundline into your stylesheet.
Features
- Linear, radial and conic gradients, plus repeating versions for stripes and rings.
- Unlimited colour stops with exact percentage positions.
- Colour blending in sRGB, OKLab or OKLCH (
in oklchsyntax). - Accepts HEX, rgb(), hsl(), oklch() and named colours in every stop.
- Six presets and a random generator to get started quickly.
Frequently asked questions
Why does my gradient look grey or muddy in the middle?
Classic CSS gradients blend in sRGB, and opposite colours like blue and yellow pass through grey. Switch colour blending to OKLab or OKLCH: the midpoint stays bright because those spaces mix colours the way the eye sees them.
Do OKLCH gradients work in all browsers?
Chrome and Edge 111+, Safari 16.2+ and Firefox 127+ support the “in oklch” syntax. For older browsers, put a normal gradient line first and the OKLCH line after it; browsers that don’t understand the second line keep the first.
How do I make hard stripes instead of a smooth blend?
Give two neighbouring stops the same position, for example red at 50% and blue at 50%. For a repeating pattern, tick Repeating and keep the last stop well below 100%, such as 0% and 10%.
What is a conic gradient used for?
Conic gradients sweep colours around a centre point, like a clock hand. They are handy for pie charts, colour wheels, loading spinners and shiny metallic effects.
Written by Dewan Razib