02

Metaballs

Five points orbit on offset sine paths and sum into a single inverse-square field, thresholded into soft, merging blobs. Colours blend in OKLab, so the violet ramp stays clean, and the cursor gently swirls the field around it.

metaballsOKLabswirl cursor
Live

Installation

Add it to your project

$
pnpm dlx shadcn@latest add https://funshader.com/r/metaballs.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 { MetaballsShader } from "@/components/shaders/metaballs/metaballs-shader";

export function Hero() {
  return (
    <section className="relative isolate min-h-svh overflow-hidden">
      <MetaballsShader 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[]["#02010A", "#04052E", "#3D2C8D", "#916BBF"]Palette, low → high. Hex strings or 0–1 RGB triplets, up to 8.
speednumber0.84Multiplier on elapsed seconds.
scalenumber1.82Zoom. Higher values show more of the field.
intensitynumber0.54Mass.
paramAnumber0.72Edge.
warpnumber0.01Amount of organic domain warp.
detailnumber3.14Frequency of the warp noise.
contrastnumber0.91Colour grade: contrast.
brightnessnumber0Colour grade: brightness offset.
saturationnumber1Colour grade: saturation.
huenumber0Hue rotation in radians.
vignettenumber0.36Edge darkening, 0–1.
blurnumber0.01Soft 5-tap blur radius.
grainnumber0.07Film grain amount.
seednumber6975Noise seed.
rotationnumber0.59Field rotation in radians.
driftnumber0.06Slow positional drift.
oklabbooleantrueBlend palette colours in OKLab.
offset[number, number][-0.1,0.18]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