Colour CSS

CSS gradient generator

0%
100%

Generated in your browser · nothing is uploaded

Live preview · the CSS is what you see

Builds a linear-gradient, radial-gradient or conic-gradient with as many colour stops as you want, previewed live, and gives you the CSS that produced exactly what you are looking at.

How to use the css gradient generator

1 Pick linear, radial or conic. The angle belongs to linear and conic; on radial the slider is not there at all, because a gradient radiating from the centre has no direction to turn.
2 Drag the angle and move the colour stops along the line.
3 Add stops for a multi-colour blend, or drag two on top of each other for a hard edge.
4 Copy the CSS, which is the same declaration the preview above it is running.
5 Add an interpolation space by hand if you want one, since this emits the sRGB default.

The angle in a CSS linear gradient is not the one most people expect. 0deg points up and the angle turns clockwise, so 90deg runs left to right and 180deg runs top to bottom. The opposite convention governs school trigonometry and SVG, both of which start at three o’clock and turn anticlockwise, and it is the usual reason a gradient copied out of a design tool arrives mirrored. The radial mode ignores the angle entirely, because a gradient radiating from the centre has no direction to rotate, and the conic mode uses it as a starting point rather than a direction: conic-gradient(from 135deg, …) sets where the sweep begins.

Interpolation is the part that changes how a gradient looks rather than where it points. A blend between two colours is a straight line drawn through a colour space, and by default that space is sRGB. Draw a line from blue to yellow in sRGB and it passes exactly through the middle grey, which is why that particular blend always looks dirty. Naming a better space fixes it: linear-gradient(135deg in oklch, blue, yellow) holds the lightness steady and travels through the colours a person would predict. The keyword sits inside the same first argument as the angle, with no comma between them, and it can appear on its own when there is no angle. Nothing here emits it, so it is one word to add after copying.

For the polar spaces there is a second control, because a hue can be reached going either way round the wheel. Adding shorter hue, longer hue, increasing hue or decreasing hue after the space picks the route; shorter hue is the default and takes the smaller arc. longer hue on two nearby colours sends the blend the long way round through everything else, which is how a rainbow sweep gets made from two stops.

Two details catch people out. A gradient with two stops at the same position does not blend at all: it changes abruptly, and that hard edge is how CSS-only stripes and split backgrounds are made without an image. And fading to the transparent keyword is fading to transparent black, since that is how the keyword is defined. Browsers premultiply alpha in gradients now, which hides most of the resulting grey cast, but naming your own colour at zero alpha removes the question entirely.

What people use it for

  • Backing a hero section without shipping an image file
  • Making a striped or two-tone panel out of stops at the same position
  • Fixing a gradient that came out mirrored after a design-tool hand-off
  • Getting a blue-to-yellow blend that does not pass through grey
  • Building a conic gradient for a pie chart or a colour wheel
  • Fading an image out at its edge without a mask
  • Reading back the exact CSS for a gradient tuned by eye

Questions

In CSS 0deg points up and the angle turns clockwise, so 90deg runs left to right. Maths and SVG both start at three o’clock and turn the other way, which is where the mismatch comes from.

MDN, linear-gradient()CSS Images Module Level 4, gradients and colour interpolation
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding