CSS has no mesh gradient function, but you can get the same soft, flowing look by stacking several radial-gradient() layers, each fading from one colour to transparent, on top of a base colour. The result is a few hundred bytes of CSS instead of an image, it stays sharp at any size, and it works in every modern browser.
Key takeaways
- A CSS mesh gradient is several
radial-gradient()layers in onebackground, each positioned withat x% y%. - Each layer fades to
transparent, so the colours blend where they overlap and the base colour shows through elsewhere. - Three or four colour points look calm; five or six look busier and more painterly.
- Add light grain to hide colour banding on large gradients.
What is a mesh gradient?
In design apps such as Figma, Illustrator and Affinity, a mesh gradient blends colours across a grid of points rather than along a single line. Each point pulls its colour outwards, so you get organic pools of colour that melt into each other. They are popular for hero backgrounds, app splash screens, album art and brand illustrations because they feel softer and more natural than a straight two-colour gradient.
A true mesh is a warped grid of colour patches. Browsers don’t have that, but layered radial gradients come very close for most uses, and they are much lighter than exporting a large PNG or JPEG.
How do you make a mesh gradient in CSS?
Here is a four-point mesh. Each layer is an ellipse of colour that fades out by a set distance, and the last value is the base colour underneath everything:
.hero {
background-color: #1b1530;
background-image:
radial-gradient(at 18% 22%, #ff7a59 0px, transparent 55%),
radial-gradient(at 82% 18%, #7b5cff 0px, transparent 50%),
radial-gradient(at 70% 85%, #2ec5ff 0px, transparent 55%),
radial-gradient(at 25% 80%, #ffcf5c 0px, transparent 45%);
}
Three parts do the work:
at 18% 22%places the centre of each colour point. Percentages mean the mesh scales with the element.transparent 55%sets how far the colour spreads before fading out. Larger values give a softer, more blended mesh; smaller ones give distinct pools.- Layer order matters. The first gradient in the list is drawn on top. Put your strongest accent first if you want it to dominate.
What makes a mesh gradient look good?
| Choice | What works | What to avoid |
|---|---|---|
| Colours | Neighbours on the colour wheel plus one accent | Complementary pairs blending into grey-brown mud |
| Base colour | A darker tone for depth, or a pale one for a light theme | Pure black or white, which looks flat at the edges |
| Number of points | 3–4 for calm backgrounds | More than 6, which starts to look noisy |
| Spread | 45–60% for soft blends | Under 30%, which gives hard-edged circles |
| Texture | Light grain over the top | Very large smooth areas, which can band |
Large smooth gradients can show visible steps of colour, called banding, on some screens. A faint layer of noise breaks those steps up; see our guide to adding grain to CSS gradients.
Mixing two colours from opposite sides of the colour wheel, such as orange and blue, can produce a dull grey patch where they overlap. Browsers interpolate gradients in sRGB by default. You can ask for a smoother blend with radial-gradient(in oklch at 18% 22%, ...), which keeps the midpoints brighter. Our guide to building a palette with OKLCH explains why.
How do you keep text readable on a mesh gradient?
A mesh has light and dark areas, so text that passes contrast in one corner can fail in another. Check your text colour against both the lightest and the darkest parts of the gradient with a contrast checker. If one area is too close, either move that colour point away from the text, darken the base colour, or place the text on a frosted glass panel, which also suits the mesh style well.
Accessibility: Normal body text needs a contrast ratio of at least 4.5:1 for WCAG AA. Our guide to WCAG contrast ratios covers the details.
Can you animate a CSS mesh gradient?
Yes, with registered custom properties. Normally the browser can’t smoothly transition between two background-image values, but if you register each position with @property, it knows they are percentages and can animate them. @property has been supported in every major browser since July 2024.
@property --x1 { syntax: "<percentage>"; inherits: false; initial-value: 18%; }
.hero {
background-image:
radial-gradient(at var(--x1) 22%, #ff7a59 0px, transparent 55%),
radial-gradient(at 82% 18%, #7b5cff 0px, transparent 50%);
animation: drift 12s ease-in-out infinite alternate;
}
@keyframes drift { to { --x1: 40%; } }
@media (prefers-reduced-motion: reduce) {
.hero { animation: none; }
}
Keep the movement slow and subtle. Repainting a full-screen gradient every frame costs more than a static one, so test on a low-powered phone, and always switch the animation off for people who prefer reduced motion.
Should you use CSS or an image?
CSS wins for most backgrounds: it is tiny, it scales to any screen without blurring, and you can change the colours in seconds. An image makes sense when you need a true warped mesh from a design app, a very complex painterly result, or the exact same artwork in places that can’t render CSS, such as emails and social preview images. For those, export a WebP or AVIF and keep it as small as you can; our guide to compressing images helps.
Using mesh gradients in WordPress and page builders
Pick your builder from the “Paste into” menu above the generated code. Refract rewrites the CSS for Elementor, Divi, Bricks, Breakdance or the block editor and shows the steps for where it goes, so the gradient only applies to the section you paste it into.
Build one in the browser
The Refract mesh gradient generator lets you drag colour points around a live preview, set the base colour and softness, add subtle grain and copy the CSS. For simple two- or three-colour gradients, the CSS gradient generator is quicker.
Last checked: October 2026.
Sources: MDN: radial-gradient(), MDN: @property, MDN: color-interpolation-method.


