Mesh Gradient
Blend two to six colors as soft drifting points, with optional distortion, swirl, and grain.
Overview
Mesh Gradient treats each color as a soft point that drifts slowly across the surface on its own path. Every pixel blends the points by distance, in linear light, so neighboring colors mix cleanly instead of turning muddy. Noise distortion bends the boundaries into organic shapes, and swirl twists the field around the center.
Use it for hero backgrounds, empty states, and cards that need a calm sense of motion. Two or three related colors read as a refined wash; four to six give a richer, more editorial field.
Installation
Usage
import { MeshGradient } from "honestui/shaders"
<div className="h-80 bg-[#9aa9cf]">
<MeshGradient
className="size-full"
colors={["#f3ebe2", "#e5b9a4", "#9aa9cf", "#3e4a70"]}
distortion={0.6}
swirl={0.25}
/>
</div>Give the parent a background color close to the gradient's average. It shows while WebGL starts and stays as the fallback where WebGL2 is unavailable.
Accessibility
Mesh Gradient is decorative: its canvas is hidden from assistive technology, so keep headings, text, and actions in normal HTML above it. Check text contrast against the lightest and darkest colors, since every color passes behind the foreground over time.
The effect pauses while it is offscreen or the tab is hidden, and shows a still frame when the user prefers reduced motion. Use paused to stop it for application reasons; prop changes still redraw the still frame.