Mesh gradient
Playground
Move cursor over canvas to interact
Variant
Pointer warp
Install
npm install @shavin/fximport { MeshGradient } from "@shavin/fx";Works with
React
Client component; Next.js and any React 18+ app
Remotion
Frame-exact through FxTimeProvider or time
Anatomy
import { MeshGradient } from "@shavin/fx";
// Theme palette: built from the brand colour, follows light and dark
<div className="relative w-full h-80 rounded-[var(--radius-panel)] overflow-hidden">
<MeshGradient
speed={0.4}
distortion={0.65}
grain={0.05}
interactive={true}
className="w-full h-full"
/>
</div>
// Custom palette: the first four colours are used
<MeshGradient
colors={["#52b788", "#2d6a4f", "#74c69d", "#081c15"]}
speed={0.3}
distortion={0.5}
/>Examples
Theme palette
With no colors the gradient is built from the brand colour and redraws when the theme switches between light and dark.
Component Source
<div className="relative w-full h-64 rounded-[var(--radius-panel)] overflow-hidden border border-hairline">
<MeshGradient
speed={0.3}
distortion={0.5}
grain={0.04}
interactive={true}
className="w-full h-full"
/>
</div>Custom palette
Four colours passed as an array. Values can be CSS colours or token names such as brand; the effect reads the first four.
Component Source
<div className="relative w-full h-64 rounded-[var(--radius-panel)] overflow-hidden border border-hairline">
<MeshGradient
colors={["#52b788", "#2d6a4f", "#74c69d", "#081c15"]}
speed={0.35}
distortion={0.6}
grain={0.04}
interactive={true}
className="w-full h-full"
/>
</div>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| colors | FxPalette: "theme" | "native" | "brand-dark" | "brand-light" | string[] | { light: string[]; dark: string[] } | "theme" | Palette. "theme" derives the gradient from the brand colour and follows light/dark ("native" is the same look); "brand-dark" / "brand-light" force one side; an array of colours (or { light, dark } arrays) is custom; the first 4 are used. |
| speed | number | 0.4 | Animation speed multiplier. |
| distortion | number | 0.6 | How far the noise displaces the colours, roughly 0 to 1. |
| grain | number | 0.04 | Film grain over the gradient, 0 to 0.2. |
| interactive | boolean | true | The gradient warps around the pointer (mouse, touch and pen). Ignored under reduced motion and when time is set. |
| blendMode | "normal" | "screen" | "overlay" | "normal" | How the gradient blends with what sits behind it (CSS mix-blend-mode). |
| time | number | — | Controlled time in seconds (e.g. frame / fps in Remotion): draws exactly this moment and runs no clock of its own. Also read from FxTimeProvider. |