03

Mesh Gradient

Each palette colour is a soft gaussian point on its own slow orbit. The points are blended by weight into a continuous mesh gradient, and the cursor gently swirls it. The default palette is monochrome graphite. Swap in your brand colours and it becomes a quiet hero backdrop.

Adapted from Paper Shaders · Apache-2.0

mesh gradientOKLabswirl cursor
Live

Installation

Add it to your project

$
pnpm dlx shadcn@latest add https://funshader.com/r/mesh-gradient.json

Installs 5 files into components/shaders. The engine is shared, so a second shader only adds its own three files.

Usage

Mount it behind your content

app/hero.tsx
import { MeshGradientShader } from "@/components/shaders/mesh-gradient/mesh-gradient-shader";

export function Hero() {
  return (
    <section className="relative isolate min-h-svh overflow-hidden">
      <MeshGradientShader className="-z-10" />
      {/* your content */}
    </section>
  );
}

The shader fills its nearest positioned ancestor. Give the parent relative isolate and the shader -z-10 to put it behind everything else. The cursor is tracked on the window, so content on top doesn’t block it.

API reference

Props

PropTypeDefaultDescription
colorsShaderColor[]["#101010", "#F5F5F5", "#B0B0B0", "#3A3A3A"]Palette, low → high. Hex strings or 0–1 RGB triplets, up to 8.
speednumber0.57Multiplier on elapsed seconds.
scalenumber1.26Zoom. Higher values show more of the field.
intensitynumber0.35Spread.
paramAnumber0.28Softness.
warpnumber0Amount of organic domain warp.
detailnumber1.82Frequency of the warp noise.
contrastnumber1Colour grade: contrast.
brightnessnumber0Colour grade: brightness offset.
saturationnumber1Colour grade: saturation.
huenumber0Hue rotation in radians.
vignettenumber0Edge darkening, 0–1.
blurnumber0Soft 5-tap blur radius.
grainnumber0.04Film grain amount.
seednumber1310Noise seed.
rotationnumber0Field rotation in radians.
driftnumber0Slow positional drift.
oklabbooleantrueBlend palette colours in OKLab.
offset[number, number][0,0]Pans the field.
cursorPartial<ShaderCursor>{"effect":"swirl","strength":0.2,"radius":0.46,"follow":"direct"}Pointer effect: push, lens, swirl, ripple, glow or none.
pausedbooleanfalseFreezes the current frame.
maxDprnumber2Cap on devicePixelRatio.
respectReducedMotionbooleantrueDraws a still frame for prefers-reduced-motion.
classNamestring—Classes for the absolutely-positioned wrapper.

Keep exploring

More shaders