Mesh Gradient CSS: Build Stripe-Style Backgrounds Without Images
September 30, 2026 | 10 min read | CSS
By Syed · Frontend Engineer & Creator of UITweak
Those soft, colorful hero backgrounds you see on Stripe, Linear, and half the landing pages launched this year are not images. They are mesh gradients: several blurred color blobs layered over a base color, rendered entirely in CSS. No PNG, no JPG, no extra HTTP requests. This guide shows the exact pure-CSS recipe, how to pick colors that blend instead of turning muddy, and when to ship CSS versus SVG.
Shortcut: design your mesh visually and export production CSS in our free Mesh Gradient Generator. Everything below is what the tool generates under the hood.
1. The Core Recipe: Stacked Radial Gradients
A mesh gradient is just multiple radial-gradient() layers stacked in one background declaration, each fading to transparent, over a solid base color. Here is the whole technique in four lines:
.hero {
background:
radial-gradient(circle at 15% 20%, oklch(72% 0.16 250), transparent 60%),
radial-gradient(circle at 85% 25%, oklch(70% 0.18 320), transparent 55%),
radial-gradient(circle at 50% 90%, oklch(75% 0.14 180), transparent 65%),
oklch(25% 0.05 260);
}Each layer is a colored circle positioned somewhere on the element (circle at 15% 20%), fading from full color to transparent at 60% of its radius. The last layer has no transparency: it is the base color everything sits on. That is the entire trick. Everything else in this guide is about making those four lines look good.
2. Paint Order: First Listed Is On Top
With multiple backgrounds, CSS paints the first layer on top and the last one at the bottom. This matters when blobs overlap: the blob you list first wins the overlap region. Put your most important accent color first, supporting colors after it, and the base color last.
/* Blue blob covers the overlap, purple sits behind it */
background:
radial-gradient(circle at 30% 40%, oklch(70% 0.16 250), transparent 60%),
radial-gradient(circle at 60% 50%, oklch(68% 0.17 310), transparent 60%),
oklch(24% 0.04 260);
/* Swap the order and purple wins the overlap instead */
background:
radial-gradient(circle at 60% 50%, oklch(68% 0.17 310), transparent 60%),
radial-gradient(circle at 30% 40%, oklch(70% 0.16 250), transparent 60%),
oklch(24% 0.04 260);3. Picking Colors That Blend Instead of Turning Muddy
The classic beginner mistake is picking three favorite colors and getting gray-brown soup where they meet. Two rules fix this:
- Stay near each other on the color wheel. Colors 60 to 90 degrees apart (blue to purple to pink, or teal to green to lime) blend into rich intermediates. Colors 180 degrees apart (blue and orange) mix into mud in the overlap zone.
- Use OKLCH, not hex. The
oklch()color space blends hues far more evenly than sRGB hex values, so the transition zones look smooth instead of dirty. All modern browsers support it. Keep lightness similar across blobs (all around 68 to 75%) and vary the hue:oklch(72% 0.16 250),oklch(70% 0.17 300),oklch(72% 0.15 340).
A reliable starting palette: one cool color, one mid color, one warm color, all at similar lightness. Blue, violet, and magenta almost never fail. Teal, green, and warm yellow work for lighter themes.
4. Placing the Blobs: Think in a Grid
Random positions look random. Stripe-style meshes place blobs like points on a loose grid so the color is distributed evenly:
- One blob in each quadrant: top-left, top-right, bottom-left, bottom-right.
- Keep blobs 15 to 25% away from the edges so color does not get clipped.
- Let blobs overlap by roughly a third. No overlap gives isolated dots; total overlap gives one flat color.
- Use different fade distances (55%, 65%, 75%) so the blobs feel organic, not stamped.
.hero {
background:
radial-gradient(circle at 20% 25%, oklch(70% 0.16 260), transparent 65%),
radial-gradient(circle at 80% 20%, oklch(69% 0.17 310), transparent 60%),
radial-gradient(circle at 25% 80%, oklch(71% 0.15 200), transparent 70%),
radial-gradient(circle at 78% 78%, oklch(70% 0.18 340), transparent 55%),
oklch(26% 0.05 265);
}5. Controlling Softness
The second value in each gradient (transparent 60%) is the fade distance, and it is your softness dial. A small value like 40% makes a tight glow with a visible edge. A large value like 75% makes a wide, barely-there wash. Stripe-style backgrounds live in the 55 to 70% range: soft enough to feel ambient, defined enough to read as color.
You can also add a hard stop for a subtle ring effect, though this is rarely what you want in a mesh:
/* Mostly soft, with a faint defined core */
radial-gradient(circle at 50% 50%, oklch(70% 0.16 280) 0%, oklch(70% 0.16 280 / 0.6) 35%, transparent 70%)6. A Complete Stripe-Style Hero, Copy-Paste Ready
Putting it together: a dark hero with a blue-violet-magenta mesh, readable text on top, and a fallback background color for very old browsers:
.hero {
/* Fallback for ancient browsers */
background-color: #1a1033;
background:
radial-gradient(circle at 18% 22%, oklch(68% 0.17 265), transparent 62%),
radial-gradient(circle at 82% 18%, oklch(66% 0.19 315), transparent 58%),
radial-gradient(circle at 22% 82%, oklch(70% 0.14 195), transparent 68%),
radial-gradient(circle at 80% 80%, oklch(67% 0.18 345), transparent 60%),
oklch(24% 0.06 270);
color: white;
padding: 6rem 2rem;
}For a light theme, flip the formula: near-white base like oklch(96% 0.01 260) with pastel blobs at high lightness (oklch(88% 0.08 250) style values). The technique is identical; only the lightness range changes.
7. CSS vs SVG: Which Format to Ship
Once you design a mesh, you have a choice of formats. Here is how to decide:
- CSS gradients (this guide): smallest file size by far, often under 1 KB. Resolution independent, easy to tweak, and animatable. The right default for backgrounds.
- SVG: better when the mesh needs to scale inside a complex illustration, or when you want to reuse the same artwork across web and print. Slightly larger, but still vector-crisp at any size.
- PNG/JPG: only if you need photographic grain or texture baked in. A full-screen PNG can weigh hundreds of KB, so this is the last resort, not the starting point.
Our Mesh Gradient Generator exports CSS, SVG, React, Tailwind, and animated CSS, so you can design once and ship whichever format fits.
8. Subtle Animation Without the Jank
A slow drift makes a mesh feel alive. The performant way is to put the gradients on a pseudo-element and animate transform, which the GPU handles cheaply. Animating background-position directly repaints every frame and can stutter on low-end phones.
.hero {
position: relative;
overflow: hidden;
}
.hero::before {
content: "";
position: absolute;
inset: -15%;
background:
radial-gradient(circle at 20% 25%, oklch(70% 0.16 260), transparent 62%),
radial-gradient(circle at 80% 75%, oklch(68% 0.18 320), transparent 60%),
oklch(24% 0.06 270);
animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift {
to { transform: translate3d(4%, -3%, 0) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
.hero::before { animation: none; }
}Keep the movement small (a few percent) and the duration long (12 to 20 seconds). The goal is ambient motion, not a screensaver. Always include the prefers-reduced-motion guard.
9. Mistakes to Avoid
- Color banding: smooth gradients can show visible steps on some displays. A whisper of grain (an SVG noise overlay at 3 to 5% opacity) breaks up banding invisibly.
- Too many blobs: beyond five or six layers the returns vanish and the CSS gets hard to maintain. Four blobs plus a base covers nearly every design.
- Text contrast: always check your headline against the brightest blob, not the base color. Add a subtle dark overlay or text shadow if needed.
- Forgetting mobile: blobs positioned with percentages reflow automatically, which is the beauty of this technique. Just double check that no blob lands directly behind your primary button on narrow screens.
If you build with Tailwind instead of vanilla CSS, read our companion guide Mesh Gradients in Tailwind CSS, which covers the same technique with arbitrary values and blend modes. And when you want the gradient itself to animate through hues rather than just drift, that needs @property, which we will cover in a future guide.
Reshaping the Falloff with Midpoint Stops
The fade distance controls how far a blob spreads, but it says nothing about the shape of the fade. By default the color falls off evenly from the center to the transparent edge. Sometimes that even falloff is the problem: the blob looks flat in the middle and then drops off too fast, or two overlapping blobs produce a dull band where they meet.
A midpoint stop fixes this. It is an extra color stop placed between the center and the transparent edge, and it bends the fade curve:
.hero {
background:
radial-gradient(circle at 25% 30%,
oklch(70% 0.16 260),
oklch(68% 0.17 285) 45%,
transparent 70%),
oklch(24% 0.05 265);
}That 45% stop pulls the blend toward a hue between the two neighbors, which kills the gray band that appears when blue fades straight into magenta. In practice I add a midpoint stop whenever an overlap zone looks muddy, and I keep the hint hue within about 30 degrees of the two endpoint hues so the shift stays invisible.
Elliptical Blobs for Wide Layouts
Circular blobs work on square cards. On a wide hero they leave the corners empty or force you to crank the fade distance until the middle turns to soup. The gradient syntax accepts an ellipse with separate horizontal and vertical radii:
.hero {
background:
radial-gradient(ellipse 70% 45% at 30% 40%, oklch(70% 0.16 250), transparent 70%),
radial-gradient(ellipse 60% 50% at 75% 60%, oklch(68% 0.18 320), transparent 70%),
oklch(24% 0.05 265);
}The two percentages are the horizontal and vertical radii, measured against the element's width and height. I prefer ellipses on anything wider than 16:9 and circles on cards and modals. One caution: elliptical percentages resolve against the element box, so the same declaration looks different on a 400px card and a 1400px hero. Design the mesh at the size it will actually render.
Themeable Meshes with @property
Hardcoded hues mean one mesh per theme. Register the hue as a typed custom property and it becomes animatable, so a theme switch can crossfade instead of snapping:
@property --blob-hue {
syntax: "<number>";
inherits: false;
initial-value: 265;
}
.hero {
background:
radial-gradient(circle at 20% 25%,
oklch(70% 0.16 var(--blob-hue)), transparent 62%),
radial-gradient(circle at 80% 75%,
oklch(68% 0.18 calc(var(--blob-hue) + 55)), transparent 60%),
oklch(24% 0.06 270);
transition: --blob-hue 1.2s ease;
}
.hero.sunset { --blob-hue: 15; }The @property registration is what makes the transition work: without it, custom properties flip instantly because the browser does not know how to interpolate them. Keep the second blob's hue as an offset from the first and the whole palette shifts together. Every current browser supports @property, and unsupported ones simply snap between themes, which is an acceptable fallback.