CSS Gradient Guide 2026: Linear, Radial, Conic, and Advanced Patterns
Master CSS linear, radial, and conic gradients with copy-paste code. Includes performance tips, animation techniques, dark mode handling, gradient mesh alternatives, and production UI design recipes.
CSS Gradient Guide 2026: Linear, Radial, Conic, and Advanced Patterns
CSS gradients are one of the most underutilized tools in frontend development. Most developers know linear-gradient for backgrounds, but gradients in 2026 go far beyond that: animated backgrounds, progress rings, gradient text, mesh-style blobs, and complex overlay patterns β all without a single image request.
This guide covers every gradient type, practical production patterns, performance rules, dark mode handling, and the advanced techniques that separate polished UIs from basic ones.
Why Gradients Instead of Images?
| Factor | CSS Gradient | Background Image |
|---|---|---|
| File size | ~100-300 bytes | 50-500 KB |
| HTTP requests | 0 (inline CSS) | 1+ |
| Resolution | β (mathematical) | Fixed (blurry on retina) |
| Animation | β Yes | β No |
| Dark mode swap | β CSS custom properties | β Harder |
| Responsive | β Scales naturally | β οΈ Requires background-size |
| Editing | β Change code | β Requires Figma/Photoshop |
The key insight: gradients render faster, scale perfectly, and can be changed with a property swap. For any background that doesnβt require a photo, a gradient is almost always the better engineering choice.
Linear Gradients
Basics
/* Direction keywords */
background: linear-gradient(to bottom, #ff0000, #0000ff); /* top β bottom */
background: linear-gradient(to right, #ff0000, #0000ff); /* left β right */
background: linear-gradient(to bottom right, #ff0000, #0000ff); /* diagonal */
/* Angle (degrees clockwise from 12 o'clock) */
background: linear-gradient(45deg, #ff0000, #0000ff); /* diagonal */
background: linear-gradient(135deg, #ff0000, #0000ff);
background: linear-gradient(0deg, #ff0000, #0000ff); /* bottom to top */
Multiple Color Stops
/* Three-stop gradient with explicit positions */
background: linear-gradient(
to bottom,
#1a1a2e 0%, /* start */
#16213e 50%, /* midpoint */
#0f3460 100% /* end */
);
/* Hard stops β create stripes (no blending) */
background: linear-gradient(
to right,
#e74c3c 0% 33%, /* red third */
#2ecc71 33% 66%, /* green third */
#3498db 66% 100% /* blue third */
);
/* Uneven bands β data visualization */
background: linear-gradient(
to right,
#e74c3c 0% 40%, /* 40% red */
#f1c40f 40% 65%, /* 25% yellow */
#2ecc71 65% 100% /* 35% green */
);
Production Color Palettes
/* Sunset */
background: linear-gradient(135deg, #f97316 0%, #ec4899 50%, #8b5cf6 100%);
/* Ocean depth */
background: linear-gradient(180deg, #06b6d4 0%, #3b82f6 50%, #8b5cf6 100%);
/* Aurora / emerald */
background: linear-gradient(90deg, #10b981 0%, #34d399 40%, #6ee7b7 70%, #a7f3d0 100%);
/* Midnight */
background: linear-gradient(180deg, #0f172a 0%, #1e293b 60%, #334155 100%);
/* Rose gold */
background: linear-gradient(135deg, #f9a8d4 0%, #e879f9 50%, #c084fc 100%);
/* Warm parchment (great for text backgrounds) */
background: linear-gradient(to bottom right, #fefce8, #fef9c3, #fef08a);
Radial Gradients
/* Circle expanding from center */
background: radial-gradient(circle, #ffffff, #1a1a2e);
/* Ellipse (default β matches container shape) */
background: radial-gradient(ellipse, #ffffff, #1a1a2e);
/* Position the center point */
background: radial-gradient(circle at top left, #ff0000, transparent);
background: radial-gradient(circle at 20% 80%, #ff0000, transparent);
background: radial-gradient(circle at center, #ff0000, transparent);
/* Control the size */
background: radial-gradient(circle closest-side, #ff0000, transparent);
background: radial-gradient(circle farthest-corner, #ff0000, transparent);
/* Spotlight / glow effect */
background: radial-gradient(
circle at 50% 30%,
rgba(255,255,255,0.15) 0%,
transparent 60%
);
Spotlight Hero Pattern
.hero {
background:
radial-gradient(
ellipse 80% 60% at 50% 40%,
rgba(99, 102, 241, 0.3) 0%,
transparent 60%
),
#0f0f1a;
}
Conic Gradients
Conic gradients rotate around a center point β enabling patterns not possible with linear or radial.
/* Pie chart */
background: conic-gradient(
#e74c3c 0deg 90deg, /* red: 0-90Β° (25%) */
#2ecc71 90deg 200deg, /* green: 90-200Β° (30.5%) */
#3498db 200deg 360deg /* blue: 200-360Β° (44.5%) */
);
/* Color wheel */
background: conic-gradient(
hsl(0, 100%, 50%),
hsl(60, 100%, 50%),
hsl(120, 100%, 50%),
hsl(180, 100%, 50%),
hsl(240, 100%, 50%),
hsl(300, 100%, 50%),
hsl(360, 100%, 50%)
);
/* Checkerboard pattern with conic + repeat */
background:
conic-gradient(#000 90deg, #fff 90deg 180deg, #000 180deg 270deg, #fff 270deg)
0 0 / 40px 40px;
/* Progress ring using clip-path on a rounded element */
.progress-ring {
background: conic-gradient(
#6366f1 0deg calc(var(--progress, 0.65) * 360deg),
#e2e8f0 0deg
);
border-radius: 50%;
--progress: 0.65; /* 65% */
}
Advanced Patterns
Gradient Text
.gradient-text {
background: linear-gradient(135deg, #6366f1, #ec4899);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
color: transparent; /* fallback */
}
Glass Morphism Card
.glass-card {
background: linear-gradient(
135deg,
rgba(255, 255, 255, 0.1),
rgba(255, 255, 255, 0.05)
);
border: 1px solid rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
border-radius: 16px;
}
Hero Section with Image Overlay
.hero {
background:
linear-gradient(
to bottom,
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.4) 60%,
rgba(0, 0, 0, 0.8) 100%
),
url('hero.jpg') center/cover no-repeat;
}
This overlay ensures text remains readable over any photo, is non-destructive, and adds zero extra HTTP requests.
Gradient Border (Pure CSS)
.gradient-border {
border: 2px solid transparent;
background:
linear-gradient(white, white) padding-box,
linear-gradient(135deg, #6366f1, #ec4899) border-box;
border-radius: 12px;
}
Noise Texture with Gradient
CSS gradients can be layered with SVG data URIs to create texture:
.textured {
background:
url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E"),
linear-gradient(135deg, #1a1a2e, #16213e);
}
Animating Gradients
The browser canβt interpolate gradient color stops directly, but you can animate gradients using several techniques:
Sliding Gradient (Best Performance)
.animated-bg {
background: linear-gradient(
135deg,
#6366f1 0%,
#ec4899 25%,
#f97316 50%,
#6366f1 75%,
#ec4899 100%
);
background-size: 200% 200%;
animation: gradientSlide 4s ease infinite;
}
@keyframes gradientSlide {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
Gradient Transition via CSS Custom Properties
.button {
--grad-start: #6366f1;
--grad-end: #8b5cf6;
background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
transition: --grad-start 0.3s, --grad-end 0.3s; /* requires Houdini/CSS Typed OM */
}
/* Workaround: transition opacity of layered pseudo-elements */
.button {
position: relative;
background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.button::after {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(135deg, #ec4899, #f97316);
opacity: 0;
transition: opacity 0.3s;
border-radius: inherit;
}
.button:hover::after {
opacity: 1;
}
Dark Mode Handling
Use CSS custom properties to swap gradient colors cleanly:
:root {
--surface-gradient-start: #f8fafc;
--surface-gradient-end: #e2e8f0;
}
@media (prefers-color-scheme: dark) {
:root {
--surface-gradient-start: #0f172a;
--surface-gradient-end: #1e293b;
}
}
.card {
background: linear-gradient(
to bottom,
var(--surface-gradient-start),
var(--surface-gradient-end)
);
}
This ensures your gradients respect system preferences without duplicating selectors throughout your stylesheet.
Performance Rules
Rule 1: Limit Gradient Layers
Each gradient layer forces the browser to composite an additional texture during rendering. Stacking more than 3-4 gradient layers on scroll-intensive pages can drop frame rate on mobile devices.
/* β Too many layers β causes compositing overhead */
background:
radial-gradient(circle at 10% 50%, rgba(255,255,255,0.1), transparent 20%),
radial-gradient(circle at 90% 50%, rgba(255,255,255,0.1), transparent 20%),
radial-gradient(circle at 50% 10%, rgba(255,255,255,0.1), transparent 20%),
radial-gradient(circle at 50% 90%, rgba(255,255,255,0.1), transparent 20%),
linear-gradient(to bottom, #1a1a2e, #0f0f23);
/* β
Keep to 2-3 layers */
background:
radial-gradient(ellipse 80% 50% at center, rgba(99,102,241,0.2), transparent),
linear-gradient(to bottom, #1a1a2e, #0f0f23);
Rule 2: Will-Change for Animated Gradients
.animated-gradient {
will-change: background-position;
/* Moves gradient animation to GPU compositor layer */
}
Rule 3: Avoid Animating Fixed/Sticky Elements with Complex Gradients
Fixed and sticky elements repaint on every scroll frame. A complex gradient on a sticky header triggers gradient repaint on every scroll pixel. Use solid colors or simple gradients on fixed/sticky elements, or promote the element to its own compositor layer.
Browser Support
| Gradient Type | Chrome | Firefox | Safari | Edge |
|---|---|---|---|---|
linear-gradient | β 26+ | β 16+ | β 7+ | β 12+ |
radial-gradient | β 26+ | β 16+ | β 7+ | β 12+ |
conic-gradient | β 69+ | β 83+ | β 12.1+ | β 79+ |
background-clip: text | β | β | β | β |
Conic gradients have full browser support since 2021. All gradient types are safe to use without vendor prefixes in 2026.
Quick Reference
/* Gradient text */
background: linear-gradient(135deg, #6366f1, #ec4899);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
/* Image overlay for readable text */
background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.7) 100%),
url('photo.jpg') center/cover;
/* Animated sliding gradient */
background: linear-gradient(135deg, #6366f1, #ec4899, #6366f1);
background-size: 200% 200%;
animation: slide 3s ease infinite;
@keyframes slide { 0%,100% { background-position: 0% 50% } 50% { background-position: 100% 50% } }
/* Progress ring */
background: conic-gradient(#6366f1 0deg calc(var(--p) * 360deg), #e2e8f0 0deg);
Summary
CSS gradients are more powerful than most developers use them for. The key ideas:
- Linear: directional color transitions, stripes, section backgrounds
- Radial: spotlight effects, glows, circular patterns
- Conic: pie charts, progress rings, color wheels
- Layering: stack gradients + images for overlay effects
- Animation: animate
background-positionfor smooth effects - Dark mode: CSS custom properties make swapping trivial
- Performance: stay under 3 layers on scroll-heavy elements
Replace any static color background with a subtle gradient and the visual quality of your UI improves immediately. Use CSS gradient tools to explore colors without writing code, then copy the exact property value.
50 CLI Commands That Save Hours Every Week
The exact Git shortcuts, file search tricks, Docker commands, and productivity hacks that senior developers use daily. Compiled from 5+ years of shipping production code.
- Git mastery (10 cmds)
- File & search wizardry
- Docker & DevOps tricks
- Process & network tools
- Productivity boosters
- macOS & Linux install guide
No spam. 1 email/week max. Unsubscribe anytime.
Found this guide useful? Check out our free developer tools.
Affiliate disclosure: Some links below are affiliate links β we may earn a small commission at no extra cost to you. Learn more.
Recommended Tools & Resources
DigitalOcean
$200 credit for new users. Simple, affordable cloud hosting for developers.
GitHub Student Pack
Free access to 100+ developer tools. Perfect for students and new devs.
Vercel
Deploy frontend apps instantly. Free tier is generous for side projects.
DevPlaybook Products
Boilerplates, scripts & AI toolkits to 10x your dev workflow.