CSS Gradient

Pick colors, drag the angle, preview the linear-gradient live and copy the CSS in one click.

Angle 135°
CSS code
Click a swatch to change its color; “Random” generates a pleasing two- or three-color gradient.

The three gradient types

TypeDirectionTypical use
linear-gradientAlong a straight line at any angleButtons, headers, background bands
radial-gradientOutward from a centre pointSpotlights, glows, vignettes
conic-gradientSweeping around a centrePie charts, colour wheels, progress rings

A linear gradient's angle is measured clockwise from the top, so 0deg runs bottom-to-top and 90deg runs left-to-right. Keywords such as to bottom right are usually easier to read than the equivalent angle.

Colour stops, hard and soft

Each stop is a colour with an optional position: linear-gradient(90deg, #6366f1 0%, #a855f7 100%). Moving two stops to the same position produces a hard edge with no blending — a neat way to build striped bars and pie slices without extra elements. Leaving a position out lets the browser distribute the stops evenly.

Why gradients go grey in the middle

Browsers interpolate in sRGB by default, which is not perceptually uniform. Blending complementary colours — orange to blue, say — passes through a muddy grey rather than the vivid middle you expected. The fix is to interpolate in a perceptual space, which modern CSS supports by naming it inside the function, or to hand-place an intermediate stop that is more saturated than the average of the two ends.

Practical notes

Fading to transparent without going grey

The keyword transparent is shorthand for rgba(0, 0, 0, 0) — fully transparent black. Interpolating toward it blends the colour channels as well as the alpha, so an orange fading to transparent passes through a dirty brown before it disappears. The fix is to name the same colour with zero alpha instead:

/* fades through grey-brown */
background: linear-gradient(to right, #f97316, transparent);

/* stays orange the whole way */
background: linear-gradient(to right, #f97316, rgba(249,115,22,0));

The difference is obvious over photographs and video, where a grey band reads as a rendering fault rather than a fade. The same applies to box-shadow and text-shadow, which have the identical behaviour.

Related tools

Colour converter Colour palette Box shadow

FAQ

Which browsers support the generated CSS?
It is standard linear-gradient syntax, natively supported by Chrome, Firefox, Safari, Edge and all major mobile browsers — no -webkit- prefix needed.
Can I generate more than three colors?
We offer two-color and three-color modes; in three-color mode each stop is independently pickable, and stops are ordered in the generated CSS so you can add or remove more by hand.
Are my colors uploaded?
No. All computation and preview happen locally in your browser; nothing is sent anywhere.