{"id":100,"date":"2026-10-18T17:53:13","date_gmt":"2026-10-18T17:53:13","guid":{"rendered":"https:\/\/refracttools.com\/blog\/?p=100"},"modified":"2026-10-18T17:53:13","modified_gmt":"2026-10-18T17:53:13","slug":"css-mesh-gradient","status":"publish","type":"post","link":"https:\/\/refracttools.com\/blog\/css-techniques\/css-mesh-gradient\/","title":{"rendered":"CSS mesh gradients without images"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">CSS has no mesh gradient function, but you can get the same soft, flowing look by stacking several <code>radial-gradient()<\/code> 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.<\/p>\n\n\n\n<div class=\"wp-block-group is-style-refract-takeaways is-layout-constrained wp-block-group-is-layout-constrained\">\n<h3 class=\"wp-block-heading\">Key takeaways<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A CSS mesh gradient is several <code>radial-gradient()<\/code> layers in one <code>background<\/code>, each positioned with <code>at x% y%<\/code>.<\/li>\n\n\n<li>Each layer fades to <code>transparent<\/code>, so the colours blend where they overlap and the base colour shows through elsewhere.<\/li>\n\n\n<li>Three or four colour points look calm; five or six look busier and more painterly.<\/li>\n\n\n<li>Add light grain to hide colour banding on large gradients.<\/li>\n<\/ul>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">What is a mesh gradient?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A true mesh is a warped grid of colour patches. Browsers don&#8217;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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you make a mesh gradient in CSS?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.hero {\n  background-color: #1b1530;\n  background-image:\n    radial-gradient(at 18% 22%, #ff7a59 0px, transparent 55%),\n    radial-gradient(at 82% 18%, #7b5cff 0px, transparent 50%),\n    radial-gradient(at 70% 85%, #2ec5ff 0px, transparent 55%),\n    radial-gradient(at 25% 80%, #ffcf5c 0px, transparent 45%);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Three parts do the work:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>at 18% 22%<\/code><\/strong> places the centre of each colour point. Percentages mean the mesh scales with the element.<\/li>\n\n\n<li><strong><code>transparent 55%<\/code><\/strong> sets how far the colour spreads before fading out. Larger values give a softer, more blended mesh; smaller ones give distinct pools.<\/li>\n\n\n<li><strong>Layer order matters.<\/strong> The first gradient in the list is drawn on top. Put your strongest accent first if you want it to dominate.<\/li>\n<\/ul>\n\n\n<aside class=\"tool-card tool-card--inline\"><span class=\"swatch\" style=\"background:radial-gradient(at 20% 20%,#5ce1c6,transparent 60%),radial-gradient(at 80% 80%,#ff6fb1,transparent 60%),#0d1b4c\" aria-hidden=\"true\"><\/span><div class=\"tool-card__body\"><p class=\"tool-card__eyebrow\">Free tool<\/p><p class=\"tool-card__name\">Mesh gradient generator<\/p><p class=\"tool-card__blurb\">Soft, flowing mesh gradients you build by dragging colour points.<\/p><\/div><a class=\"btn primary\" href=\"https:\/\/refracttools.com\/mesh-gradient-generator\/\">Try it free <span aria-hidden=\"true\">\u2192<\/span><\/a><\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">What makes a mesh gradient look good?<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"table-scroll\" tabindex=\"0\" role=\"region\" aria-label=\"Scrollable table\"><table><thead><tr><th>Choice<\/th><th>What works<\/th><th>What to avoid<\/th><\/tr><\/thead><tbody><tr><td>Colours<\/td><td>Neighbours on the colour wheel plus one accent<\/td><td>Complementary pairs blending into grey-brown mud<\/td><\/tr><tr><td>Base colour<\/td><td>A darker tone for depth, or a pale one for a light theme<\/td><td>Pure black or white, which looks flat at the edges<\/td><\/tr><tr><td>Number of points<\/td><td>3\u20134 for calm backgrounds<\/td><td>More than 6, which starts to look noisy<\/td><\/tr><tr><td>Spread<\/td><td>45\u201360% for soft blends<\/td><td>Under 30%, which gives hard-edged circles<\/td><\/tr><tr><td>Texture<\/td><td>Light grain over the top<\/td><td>Very large smooth areas, which can band<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">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 <a href=\"\/blog\/css-techniques\/css-grain-texture\/\">adding grain to CSS gradients<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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 <code>radial-gradient(in oklch at 18% 22%, ...)<\/code>, which keeps the midpoints brighter. Our guide to <a href=\"\/blog\/ui-design\/oklch-color-palette-css\/\">building a palette with OKLCH<\/a> explains why.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do you keep text readable on a mesh gradient?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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 <a href=\"https:\/\/refracttools.com\/contrast-checker\/\">contrast checker<\/a>. 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 <a href=\"\/blog\/css-techniques\/glassmorphism-css-backdrop-filter\/\">frosted glass panel<\/a>, which also suits the mesh style well.<\/p>\n\n\n\n<div class=\"wp-block-group is-style-refract-callout is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"wp-block-paragraph\"><strong>Accessibility:<\/strong> Normal body text needs a contrast ratio of at least 4.5:1 for WCAG AA. Our guide to <a href=\"\/blog\/ui-design\/wcag-contrast-ratio\/\">WCAG contrast ratios<\/a> covers the details.<\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Can you animate a CSS mesh gradient?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, with registered custom properties. Normally the browser can&#8217;t smoothly transition between two <code>background-image<\/code> values, but if you register each position with <code>@property<\/code>, it knows they are percentages and can animate them. <code>@property<\/code> has been supported in every major browser since July 2024.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@property --x1 { syntax: \"&lt;percentage&gt;\"; inherits: false; initial-value: 18%; }\n\n.hero {\n  background-image:\n    radial-gradient(at var(--x1) 22%, #ff7a59 0px, transparent 55%),\n    radial-gradient(at 82% 18%, #7b5cff 0px, transparent 50%);\n  animation: drift 12s ease-in-out infinite alternate;\n}\n\n@keyframes drift { to { --x1: 40%; } }\n\n@media (prefers-reduced-motion: reduce) {\n  .hero { animation: none; }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Should you use CSS or an image?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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&#8217;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 <a href=\"\/blog\/image-optimisation\/compress-images-for-website\/\">compressing images<\/a> helps.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using mesh gradients in WordPress and page builders<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Pick your builder from the &#8220;Paste into&#8221; 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Build one in the browser<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/refracttools.com\/mesh-gradient-generator\/\">Refract mesh gradient generator<\/a> 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 <a href=\"https:\/\/refracttools.com\/css-gradient-generator\/\">CSS gradient generator<\/a> is quicker.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Last checked: October 2026.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Sources: <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/gradient\/radial-gradient\" rel=\"noopener\" target=\"_blank\">MDN: radial-gradient()<\/a>, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/@property\" rel=\"noopener\" target=\"_blank\">MDN: @property<\/a>, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/color-interpolation-method\" rel=\"noopener\" target=\"_blank\">MDN: color-interpolation-method<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSS has no mesh gradient function, but layered radial gradients get you the same soft, flowing look in a few hundred bytes. Here is how they work, how to pick colours, and how to animate them.<\/p>\n","protected":false},"author":1,"featured_media":99,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_refract_tool":"mesh-gradient-generator","footnotes":""},"categories":[8],"tags":[28,4,49],"class_list":["post-100","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css-techniques","tag-colour","tag-css-generators","tag-gradients"],"_links":{"self":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":1,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":111,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/100\/revisions\/111"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media\/99"}],"wp:attachment":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}