<radialGradient>
Core element
Define reusable centre-out paint inside <defs> with a unique id.

SVG <radialGradient> blends colours outward from a centre point. This tutorial covers defining gradients in <defs>, <stop> offsets, centre and radius with cx/cy/r, focal highlights with fx/fy, applying paint with url(#id), five worked examples, and how radial gradients compare to linear ones and patterns.
Core element
Define reusable centre-out paint inside <defs> with a unique id.
Colour stops
Set offset, stop-color, and optional stop-opacity.
Centre & radius
Control where the gradient starts and how far it spreads outward.
Focal point
Shift the highlight away from the centre for light-source effects.
Apply paint
Use fill or stroke with url(#yourId) on any shape.
Coordinate space
objectBoundingBox (default) or userSpaceOnUse for fixed coords.
SVG radial gradients blend two or more colours outward from a centre point. They add depth, glow, and polish to icons, buttons, charts, and illustrations — all while staying crisp as vectors.
You define a <radialGradient> once (usually in <defs>), list colour <stop>s, then reference it with url(#id) on fill or stroke.
Raster glow images blur when scaled. SVG radial gradients stay sharp, stay tiny in markup, and can be shared across many shapes with one definition.
Colour radiates from cx/cy to the outer edge at r.
fx/fy shift the brightest point for sphere and button effects.
Two stops for simple glows; add more for rich orbs and vignettes.
Same paint works for solid fills and outlined rings.
In short: define stops around a centre point, then paint shapes with url(#id).
Basic form of an SVG radial gradient:
<svg width="300" height="120">
<defs>
<radialGradient id="g" cx="50%" cy="50%" r="50%">
<stop offset="0%" stop-color="#fff" stop-opacity="0" />
<stop offset="100%" stop-color="#2563eb" stop-opacity="1" />
</radialGradient>
</defs>
<rect x="20" y="30" width="260" height="60" rx="12" fill="url(#g)" />
</svg> | Name | Type | Description |
|---|---|---|
<radialGradient> | Element | Defines a centre-out colour blend; place inside <defs> with an id. |
cx, cy | Length / % | Centre of the gradient (default 50%). |
r | Length / % | Radius — how far the gradient extends outward. |
fx, fy | Length / % | Optional focal point for highlight effects. |
<stop> | Element | A colour at a position along the radius. |
offset | % / number | Stop position from centre to edge, e.g. 0%, 50%, 100%. |
stop-color | Colour | Colour at that stop. |
stop-opacity | 0–1 | Optional transparency of the stop. |
gradientUnits | Keyword | objectBoundingBox (default) or userSpaceOnUse. |
| Effect | Attributes | Notes |
|---|---|---|
| Centred orb | cx="50%" cy="50%" r="50%" | Default — fills the shape evenly |
| Top-left highlight | cx="40%" cy="35%" fx="25%" fy="20%" r="70%" | Light source from upper-left |
| Edge glow | cx="50%" cy="50%" r="60%" + transparent outer stop | Centre colour fading to transparent |
<!-- 1. Define -->
<defs>
<radialGradient id="glow" cx="50%" cy="50%" r="50%">
<stop offset="0%" stop-color="#22c55e" stop-opacity="0.9" />
<stop offset="100%" stop-color="#22c55e" stop-opacity="0" />
</radialGradient>
</defs>
<!-- 2. Apply -->
<circle fill="url(#glow)" /> | Goal | Code |
|---|---|
| Define gradient | <radialGradient id="g" cx="50%" cy="50%" r="50%">...</radialGradient> |
| Two colour stops | <stop offset="0%" stop-color="white" /> + 100% stop |
| Fill a shape | fill="url(#g)" |
| Highlight offset | fx="30%" fy="25%" on <radialGradient> |
| Fade to transparent | stop-opacity="0" on the outer stop |
| Fixed coordinates | gradientUnits="userSpaceOnUse" |
All paint SVG shapes — pick the paint that matches the look you want.
centre-outHighlights, glows, orbs, and vignettes
straight blendColours along a vector — UI bars & buttons
repeating tileTextures, grids, and motifs
one colourSimplest fill when no blend is needed
Reach for <radialGradient> when colour should radiate from a centre point.
3D-looking buttons, planets, and avatar rings with centre-out shading.
Status indicators, focus rings, and light-source accents on icons.
Soft edge darkening and spotlight effects on panels and heroes.
Consistent centre-out accents across an icon set.
For left-to-right or top-to-bottom blends, use linear gradients instead.
Key benefit: one definition, many shapes — crisp centre-out blends at every scale.
Five starter snippets using <radialGradient>. Click View Output for a preview, or Try It Yourself to edit live.
Define a radial gradient, fill a shape, then shift the focal point.
Transparent centre fading to solid blue at the edges on a rounded rectangle.
<svg width="220" height="220" viewBox="0 0 220 220">
<defs>
<radialGradient id="grad1" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
<stop offset="0%" stop-color="rgb(255,255,255)" stop-opacity="0" />
<stop offset="100%" stop-color="rgb(0,0,255)" stop-opacity="1" />
</radialGradient>
</defs>
<rect x="10" y="10" width="200" height="200" rx="18" fill="url(#grad1)" />
</svg> The gradient lives in <defs>. fill="url(#grad1)" paints the rectangle with centre-out colour that fades from transparent white to solid blue.
Use fx and fy to shift the focal point and create a light-source highlight on a circle.
<svg width="240" height="160" viewBox="0 0 240 160">
<defs>
<radialGradient id="hi" cx="45%" cy="40%" r="70%" fx="30%" fy="25%">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.85" />
<stop offset="55%" stop-color="#60a5fa" stop-opacity="0.75" />
<stop offset="100%" stop-color="#1d4ed8" stop-opacity="1" />
</radialGradient>
</defs>
<circle cx="120" cy="80" r="58" fill="url(#hi)" />
</svg> fx/fy pull the brightest stop away from cx/cy, mimicking light hitting a sphere from the upper-left.
Glows, vignettes, and advanced multi-stop radial fills.
A bright centre that dissolves into transparency — ideal for status dots and focus rings.
<svg width="300" height="140" viewBox="0 0 300 140">
<defs>
<radialGradient id="glow" cx="50%" cy="50%" r="60%">
<stop offset="0%" stop-color="#22c55e" stop-opacity="0.9" />
<stop offset="100%" stop-color="#22c55e" stop-opacity="0" />
</radialGradient>
</defs>
<rect x="0" y="0" width="300" height="140" fill="#0f172a" />
<circle cx="150" cy="70" r="55" fill="url(#glow)" />
</svg> Same stop-color with falling stop-opacity creates a soft halo — no blur filter required.
Light centre darkening toward the edges — a classic vignette overlay on a panel.
<svg width="300" height="180" viewBox="0 0 300 180">
<defs>
<radialGradient id="vig" cx="50%" cy="50%" r="65%">
<stop offset="0%" stop-color="#f8fafc" stop-opacity="1" />
<stop offset="100%" stop-color="#0f172a" stop-opacity="1" />
</radialGradient>
</defs>
<rect x="20" y="20" width="260" height="140" rx="16" fill="url(#vig)" />
</svg> A large r with contrasting centre and edge stops creates a subtle spotlight frame around content.
Three colour stops on an ellipse with fixed coordinates via gradientUnits="userSpaceOnUse".
<svg width="320" height="180" viewBox="0 0 320 180">
<defs>
<radialGradient id="orb" gradientUnits="userSpaceOnUse"
cx="160" cy="90" r="80" fx="130" fy="60">
<stop offset="0%" stop-color="#fef08a" />
<stop offset="45%" stop-color="#f97316" />
<stop offset="100%" stop-color="#7c3aed" />
</radialGradient>
</defs>
<ellipse cx="160" cy="90" rx="120" ry="70" fill="url(#orb)" />
</svg> gradientUnits="userSpaceOnUse" pins cx/cy/r to absolute SVG coordinates instead of the shape’s bounding box — useful when resizing must not shift the gradient centre.
Real-world places where SVG radial gradients show up every day.
Off-centre highlights that make flat UI feel tactile.
Example: pill button with fx/fy light spot.
Online indicators and notification pulses.
Example: green centre fading to transparent halo.
Gradient strokes and fills around profile images.
Example: multi-stop orb behind a circular clip.
Spotlight frames on landing-page panels.
Example: light centre darkening toward card edges.
Logo marks and decorative spheres in icon sets.
Example: shared radial palette across product icons.
Emphasis dots and radial heat on data points.
Example: glowing marker at a peak value.
Pro Tip: keep gradient ids unique per inline SVG on a page — duplicate ids can make the wrong paint apply.
Why paint with SVG radial gradients instead of raster images or CSS alone.
Glows and orbs stay sharp on retina screens without extra assets.
One definition paints many shapes via url(#id).
fx/fy create convincing light-source effects on spheres.
Outline rings and avatar borders with the same paint system.
Swap stop colours or animate offsets without new image files.
Pro Tip: for UI glows, two stops with matching colour and fading opacity often look cleaner than many colour stops.
Follow these practices for clean, scalable SVG radial gradients.
Put gradients in <defs> (or earlier in the SVG) before url(#id).
Names like glow, hi, or vig are easier to maintain.
Extra stops are fine for orbs; keep glows and vignettes restrained.
Shift the focal point slightly off-centre for convincing sphere highlights.
Default objectBoundingBox scales with the shape; use userSpaceOnUse for fixed coords.
Pro Tip: percentage centres (50%) are easiest when you stay on the default bounding-box units.
Avoid these mistakes when your gradient refuses to show up.
fill="url(#missing)" paints nothing useful.
→ Match the id on <radialGradient> exactly.
Multiple SVGs on one page sharing the same id can collide.
→ Give each gradient a unique id per document.
If r is zero or very small, the blend collapses to a dot.
→ Use a sensible r — often 50% or larger for glows.
Percentages behave differently under userSpaceOnUse.
→ Stick to default units until you need fixed coordinates.
SVG uses <stop> elements, not CSS radial-gradient() strings inside attributes.
→ Define SVG gradients with elements, then reference via url(#id).
Pro Tip: if a fill is blank, check the id spelling, that stops exist, and that the gradient is defined in the same SVG document.
Gradients should live in <defs> so they can be reused across multiple shapes.
Each <stop> specifies a colour at a position using offset from centre to edge.
Defaults are 50% for each. Optionally shift the highlight with fx/fy.
Use fill="url(#id)" to fill shapes or stroke="url(#id)" to paint outlines.
Radial gradients make SVG graphics feel dimensional with glows, orbs, and highlights while staying crisp at any scale.
<defs> and reference them with url(#id).cx/cy/r set the centre and spread of the blend.offset + stop-color (and optional stop-opacity) build the ramp.fx/fy shift the focal highlight off-centre.objectBoundingBox — gradients scale with the shape.Quick Takeaway: define stops around a centre point, give the gradient an id, paint with url(#id). Keep ids unique on the page.
SVG <radialGradient> is supported in all modern browsers — and has been for many years — as part of SVG 1.1 paint servers.
Use radial gradients in inline SVG or external .svg files. Stops, centre/radius attributes, focal points, and url(#id) paints work consistently across Chrome, Firefox, Safari, Edge, and mobile browsers.
Bottom line: Safe for production sites. Prefer inline SVG or cached .svg assets; no polyfill is required for current browsers.
SVG radial gradients are reusable paint: define <radialGradient> with colour stops, set centre and radius with cx/cy/r, then apply with fill or stroke via url(#id).
Practice the five examples above, then return to the SVG Introduction to continue building your vector graphics toolkit.
Keep ids unique, prefer 2–3 stops for UI glows, and use fx/fy for convincing highlights.
fx/fy for realistic sphere and button highlightsgradientUnits="userSpaceOnUse" when you need fixed coordinatesstroke for elegant avatar ringsglow, hi, vig)fill/strokePaint shapes with centre-out colour blends.
Reusable paint in defs
APIoffset + stop-color
Colourcx, cy, r
Radiusfill or stroke
Applyfocal highlight
LightAn SVG <radialGradient> blends colours outward from a centre point — set the origin with cx and cy, the spread with r, then apply it with fill="url(#id)" or stroke="url(#id)". You can also animate stop-color or stop-opacity with CSS or SMIL for pulsing glow effects.
Return to the SVG Introduction hub and explore shapes, paths, and styling next.
8 people found this page helpful