The short version
- A CSS radial gradient spreads colour outwards from a centre point, and is written with the radial-gradient() function anywhere CSS accepts an image.
- By default a radial gradient is an ellipse, centred in the box, sized to reach the farthest corner.
- The size keywords closest-side, closest-corner, farthest-side and farthest-corner decide where the last colour stop lands.
- The at keyword moves the centre, for example at 20% 30%, and positions work like background-position.
- Layering several radial gradients that fade to transparent is the standard way to build soft glows and mesh-like backgrounds in CSS.
On this page
A CSS radial gradient blends colour outwards from a point, like light spreading from a lamp. You write it with radial-gradient() and use it wherever CSS takes an image, usually background-image. With no options it draws an ellipse in the middle of the box that reaches the farthest corner: radial-gradient(#fef3c7, #b45309) gives a pale centre glowing out to deep amber.
radial-gradient(#fef3c7, #f59e0b 45%, #78350f)Everything else in the function changes one of three things: the shape, the size and the position. Once you can control those, the same function draws glows, spotlights, vignettes, sunbursts and the colour pools behind a mesh gradient in CSS. For the design side of radial blends, see the companion guide to radial gradients.
The radial-gradient() syntax
/* shape size position stops */
radial-gradient(circle closest-side at 30% 40%, #fde047, #ea580c 60%, #1c1917)
/* everything before the first comma is optional */
radial-gradient(#fde047, #ea580c)| Part | Values | Default |
|---|---|---|
| Shape | circle or ellipse | ellipse |
| Size | a keyword, one length for a circle, or two lengths or percentages for an ellipse | farthest-corner |
| Position | at followed by anything background-position accepts | at center |
| Interpolation | in oklab, in oklch and other colour spaces | sRGB for hex colours |
| Colour stops | two or more colours with optional positions | required |
One rule catches people out: a circle's size must be a length such as 200px, never a percentage, because a percentage of a rectangle has no single radius. Ellipses accept percentages, as in ellipse 60% 40%. The MDN reference for radial-gradient() lists the full grammar.
Circle versus ellipse
An ellipse stretches with the box, so on a wide banner the glow is wide and on a tall story it is tall. A circle stays round whatever the box does. Use ellipses for backgrounds that should fill their container evenly, and circles for anything that should read as a light source, a planet or a button's glow.
Size keywords: closest-side to farthest-corner
The size decides where the final colour stop lands, which is where the gradient's ending shape sits. The four keywords measure from the centre to the nearest or farthest side or corner of the box. They only look different when the centre is off-centre, so the examples below all start at 30% 40%.
In practice, closest-side suits contained shapes such as dots and badges, because the colour never runs off the nearest edge. farthest-corner suits backgrounds, because the blend covers the whole box. When you need exact control, give a length: circle 180px at 50% 0 is a 180 pixel glow hanging from the top edge.
Positioning with at
The at keyword places the centre using the same values as background-position: keywords like at top right, percentages like at 20% 80%, or lengths like at 40px 60px. The centre can even sit outside the box, as in at 50% 120%, which gives a horizon glow rising from below the bottom edge.
Layered radial glows
The most useful radial pattern is several gradients stacked in one background-image, each fading to transparent, over a flat dark colour. Each layer is a pool of light in its own place. Because the first layer is painted on top, put the brightest, smallest glow first.
.glow {
background-color: #0b0a1a;
background-image:
radial-gradient(circle at 20% 25%, rgb(124 58 237 / 0.55), transparent 45%),
radial-gradient(circle at 80% 30%, rgb(236 72 153 / 0.45), transparent 40%),
radial-gradient(ellipse at 50% 110%, rgb(56 189 248 / 0.4), transparent 60%);
}Two more patterns cover most remaining jobs. A vignette darkens the edges: radial-gradient(ellipse, transparent 55%, rgb(0 0 0 / 0.55)) layered over a photo. A spotlight follows the pointer when you feed its position from custom properties, such as radial-gradient(circle 240px at var(--x) var(--y), rgb(255 255 255 / 0.15), transparent), with a few lines of JavaScript setting --x and --y on pointermove.
Repeating radial gradients
repeating-radial-gradient() repeats its stops outwards until the box is full, so a pair of hard stops becomes rings. Use lengths for the stop positions so the ring width stays constant. It is the basis of ripple, target and halftone-like textures, and the CSS patterns guide has more.
Avoid
- Percentages for a circle's size, which are invalid
- Bright glows that end in a hard edge because the last stop is opaque
- Centring every glow at 50% 50%
- Five overlapping glows of equal strength
Do
- Lengths for circles, percentages for ellipses
- Fade each glow to
transparent - Place glows off-centre, near corners or below the edge
- One dominant glow and one or two quieter ones
Questions people ask
How do I make a circle gradient in CSS?
Use radial-gradient(circle, colour1, colour2). Adding circle keeps the shape round; without it you get an ellipse that stretches with the box.
How do I move the centre of a radial gradient?
Add at and a position after the shape and size, for example radial-gradient(circle at 20% 30%, #c4b5fd, #1e1b4b). Positions work like background-position.
What does farthest-corner mean?
It sizes the gradient so its last colour stop reaches the corner of the box furthest from the centre. It is the default size.
Can a circle radial gradient use a percentage size?
No. A circle needs a single length such as 200px. Ellipses can use two percentages, such as ellipse 60% 40%.
How do I make a glow effect with CSS gradients?
Layer one or more radial-gradient() values that fade from a semi-transparent colour to transparent, over a dark background-color.
Written by Gradiently
The team behind Gradiently, a design tool built around Marks: living gradients that make everything you design look like yours.
See our profile


