Skip to content

Mesh gradient

Playground

Move cursor over canvas to interact

Variant

Pointer warp

Install

npm install @shavin/fx
import { 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

PropTypeDefaultDescription
colorsFxPalette: "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.
speednumber0.4Animation speed multiplier.
distortionnumber0.6How far the noise displaces the colours, roughly 0 to 1.
grainnumber0.04Film grain over the gradient, 0 to 0.2.
interactivebooleantrueThe 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).
timenumber—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.
Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font