Blurred color blobs that drift slowly under a layer of SVG grain. The motion is pure CSS, so it works as a server component and costs no JavaScript. Colors default to the theme primary colour and its neighbours on the hue wheel, so they always go together.
Preview
Quiet motion
A soft backdrop for hero sections and cards
Installation
Usage
The gradient fills the nearest positioned parent. Give the parent a background color, the blobs are blended over it.
import { MeshGradient } from "@/components/ui/mesh-gradient"
export default function Hero() {
return (
<section className="relative h-96 overflow-hidden bg-background">
<MeshGradient />
<h1 className="relative">Your headline</h1>
</section>
)
}Examples
Custom colors
Pass any number of colors. They cycle through five blob slots.
<MeshGradient
colors={["#f97316", "#fb7185", "#fbbf24"]}
/>Less blur, more grain
A smaller blur keeps the shapes visible, a stronger grain adds texture.
<MeshGradient blur={30} grain={0.35} />Faster and lighter
Speed scales every blob duration. Lower blobOpacity for a subtle tint.
<MeshGradient speed={3} blobOpacity={0.35} grain={0} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| colors | string[] | var(--primary) ± hue | Blob colors, any CSS color or var() |
| speed | number | 1 | Animation speed multiplier, 0 pauses it |
| blur | number | 80 | Blur radius of the blobs in pixels |
| blobOpacity | number | 0.7 | Opacity of the blobs from 0 to 1 |
| grain | number | 0.15 | Opacity of the grain layer, 0 disables it |
| className | string | - | Additional CSS classes for the wrapper |
Features
- No JavaScript: keyframes live in a deduplicated style tag
- Grain without images: feTurbulence noise in an inline data URI
- Theme aware: default colors are CSS variables, so they follow the theme
- Reduced motion: with prefers-reduced-motion the blobs stand still