Skip to content
← All articles

Tutorials ·

How to Create Animated Mesh Gradient Backgrounds in React

UI Layouts

On this page

Mesh gradients create soft color transitions that feel less linear than a two-stop CSS gradient.

Live example from UI Layouts

Select an ordered palette

Choose three or four colors with one dominant tone and one accent. Ensure any text placed over the gradient remains readable as its hues move.

Choose CSS or a shader

Layered radial gradients work for a static baseline. The library's WebGL demos offer more organic motion and configurable shader colors; use them only when the effect warrants a canvas.

Constrain the rendering cost

Keep the canvas behind content, cap pixel density and stop motion when offscreen or reduced motion is requested. Provide a static gradient fallback.

Implementation pattern

The following focused snippet demonstrates the principle, not the complete UI Layouts implementation. The live example and linked documentation contain the full source.

.mesh { background: radial-gradient(at 15% 20%, #83a9ff, transparent 55%), radial-gradient(at 80% 75%, #f0a9dc, transparent 55%), #5146aa; }

Explore the source

Open the mesh gradients component documentation for the full implementation, examples and any required dependencies. Test the interaction on a narrow screen and with keyboard navigation before adapting it to production.