CSS WebKit Logo
CSS WebKit

Linear, radial and conic gradients in one tool, with presets and oklch blending

⚡ Try the Generator

Interactive

Live preview

Generated CSS
.gradient {
  background-color: #6366f1; /* fallback while the gradient loads */
  background-image: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
}

Presets

Gradient type

Supported in current Chrome, Edge, Safari and Firefox. Older browsers ignore the whole value, so the fallback color is kept.

Color stops (3)

  • 0%
  • 50%
  • 100%

Written and maintained by W3hubs. Last reviewed against MDN and current browser support data.

About the CSS Gradient Generator

CSS has three gradient functions, and they differ only in the path the colors travel along. linear-gradient() blends along a straight line at an angle. radial-gradient() spreads outward from a center point in rings. conic-gradient() sweeps around a center point like the hand of a clock. All three produce an image with no fixed size, so they fill the element and can be stacked with other backgrounds. This tool lets you try the same stops in all three shapes.

Pick the type by the job. Linear suits large surfaces like page headers, buttons and fades over photos, where the eye should travel in one direction. Radial suits light: a glow behind a card, a spotlight, or a vignette that darkens the edges. Conic is for anything angular, such as color wheels, pie charts, loading rings and the reflections on a metal knob. If you find yourself fighting one type to fake another, switch types instead.

What each control does

Presets
Six starting points that set the type, angle and stops in one click: Indigo dusk, Ocean and Sunset are linear, Spotlight is radial, Color wheel and Pie chart are conic.
Gradient type, Angle and Start angle
Switches between linear, radial and conic. For linear the slider is the direction of the line, where 0deg points up and 90deg runs left to right. For conic the same slider becomes from, which rotates where the sweep begins, so 0deg starts at twelve o'clock.
Shape, Size and Center position
Radial only gets Shape (ellipse stretches with the box, circle stays round) and a size keyword. farthest-corner is the default and fills the box; closest-side gives the tightest spot; closest-corner and farthest-side sit in between. Center position, from a list of keywords like top left, applies to both radial and conic.
Color interpolation
Chooses the color space the browser blends in. Default leaves it out, which means sRGB for hex colors. oklab adds in oklab and gives evenly bright, smooth blends. oklch adds in oklch and keeps colors saturated by moving around the hue wheel.
Repeating
Adds the repeating- prefix so the stop pattern tiles. It only changes anything when your last stop sits below 100%. Put the last stop at 20% and the pattern repeats five times across the gradient.
Color stops
Between 2 and 8 stops, each with a color picker and a 0 to 100% position slider. The output is sorted by position. New stops land in the middle of the widest gap, and the first stop's color is also used as the background-color fallback.

Example in a real stylesheet

.hero {
  background-color: #1e1b4b;
  background-image:
    radial-gradient(circle farthest-side at top right in oklab, rgb(236 72 153 / 0.45), transparent 60%),
    linear-gradient(160deg in oklab, #312e81 0%, #1e1b4b 100%);
}

.progress__bar {
  background-color: #22c55e;
  background-image: repeating-linear-gradient(
    45deg,
    rgb(255 255 255 / 0.2) 0% 3%,
    transparent 3% 6%
  );
}

The hero layers a pink radial glow from the top right corner over a dark linear base, both blended in oklab so the fade has no muddy edge. The progress bar uses a repeating gradient with hard stops to draw diagonal stripes over a solid green fill.

Tips and common mistakes

Hard stops turn blends into shapes

When two stops share a position, there is no blend between them, only a clean edge. The Pie chart preset shows this: indigo runs from 0 to 40%, then green starts exactly at 40%. Combine hard stops with Repeating to get stripes, and with conic to get chart slices.

Why sRGB goes gray in the middle

In sRGB the browser averages the red, green and blue channels. Blue (0, 0, 255) and yellow (255, 255, 0) average to about (128, 128, 128), a flat gray, and many other pairs dip darker or duller than either end. oklab is built so equal steps look equally different, which removes the dark dip and evens out brightness. For near-opposite colors like blue and yellow, even oklab passes close to neutral, so use oklch to travel around the hue wheel instead of through the middle.

Reduce banding on big, subtle gradients

A screen with 8 bits per channel only has so many shades between two close colors. Stretch that across a full-width dark section and you see steps instead of a smooth fade. Increase the color difference, shorten the distance the blend covers, or add a faint grain texture as another background layer.

Layer instead of adding stops

Many rich backgrounds are two or three simple gradients stacked with commas in background-image, not one gradient with eight stops. The first layer paints on top, so fade it to transparent to let the layers below show through. Each layer can also have its own background-size and background-position.

Gradients are cheaper than images

A gradient costs no network request, scales to any screen density without blurring, and changes with a single edit. Use an image only for things gradients can't express, like photographic texture. Avoid animating gradients over large areas every frame; fade or move a gradient on a pseudo-element with opacity or transform instead.

Browser support: Linear, radial, conic and repeating gradients work in all current browsers, and current Chrome, Edge, Safari and Firefox also accept the in oklab and in oklch interpolation syntax; older browsers drop the whole declaration, which is why the solid fallback color matters.

Questions people ask

Why does my gradient look muddy or gray in the middle?

The default sRGB blend averages channel values, and for many color pairs that average is darker or grayer than either color. Switch Color interpolation to oklab for a smoother blend, or oklch if the colors are on opposite sides of the color wheel.

What's the difference between oklab and oklch for gradients?

oklab blends in a straight line between the two colors, so the middle can lose saturation when the colors are far apart. oklch blends the hue as an angle, so the middle passes through the hues in between, for example blue to yellow via pink and orange. oklab is safer for subtle UI fades, oklch for vivid, rainbow-like ones.

How do I make stripes with a CSS gradient?

Turn on Repeating, give each color two stops at the same position for hard edges, and keep the last stop well below 100%, for example 0 to 5% one color and 5 to 10% another. For stripes of a fixed pixel width, change the percentages to lengths like 10px in the copied code.

Sources