Skip to content
WANCRAFT

E.141Backgrounds & Effects

Voronoi Field

A drifting Voronoi mosaic with hairline cell edges — the pointer becomes a seed and the cells make room.

NewReactCanvasTailwindadvanced

Overview

Voronoi Field computes real cell geometry every frame: drifting seeds are triangulated with an inline Bowyer–Watson Delaunay pass (plus a far ring of ghost points so the edge cells close), and each cell is the polygon of circumcentres around its seed. All edges are stroked as one path, so shared edges stay true hairlines instead of doubling up. Cells can stay empty, take a flat tint, or fall off radially from their seed, in editorial palettes — clay, sea, theme ink or the accent. The pointer (or a finger while it is down) joins as a seed with its own accent cell, nearby seeds are pushed aside and drift back, and edges around it glow. Seeds start from a low-discrepancy sequence for even coverage, bounce off the walls, and the loop pauses offscreen and in hidden tabs. Reduced motion renders a single still mosaic.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/voronoi-field.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/voronoi-field.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/voronoi-field.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
13 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { VoronoiField } from "@/components/ui/voronoi-field";

export function VoronoiFieldExample() {
  return (
    <div className="relative h-80 w-full overflow-hidden rounded-xl">
      <VoronoiField />
    </div>
  );
}

03Props

PropTypeDefaultDescription
countnumber36Number of drifting seeds (8–120).
speednumber0.5Drift speed multiplier; 0 holds the mosaic still.
lineWidthnumber1Cell edge width in px.
fill"none" | "tint" | "distance""distance"Empty cells, a flat tint per cell, or a radial falloff from each seed.
palette"clay" | "sea" | "ink" | "accent""clay"Fill colours. Ink follows the theme; accent uses the accent colour.
pointerbooleantrueThe pointer (or a finger while touching) becomes a seed and pushes nearby seeds aside.
showSeedsbooleantrueDraw a small dot at every seed.
accentstring"#FF7448"Colour of the pointer's cell and of the edges near it (any CSS colour).
childrenReactNode—Optional content layered above the mosaic.
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the root, which is absolute inset-0 — place it inside a positioned parent.

04Features

  • 01Inline Bowyer–Watson Delaunay triangulation every frame; cells are circumcentre polygons
  • 02A far ring of ghost points closes the edge cells; the canvas clips them to the container
  • 03All edges stroked as a single path — shared edges never double their alpha
  • 04Fills: none, flat tint or radial distance falloff, in clay, sea, ink or accent palettes
  • 05Pointer seed with an accent cell and glowing nearby edges; neighbours are pushed aside and drift back
  • 06DPR-aware canvas (capped at 2), ResizeObserver, pauses offscreen and in hidden tabs, theme-aware ink
motion · continuousinput · pointerinput · viewport

05Accessibility

  • The canvas is aria-hidden and ignores pointer events; layered content stays fully interactive.
  • prefers-reduced-motion renders one still mosaic with no drift and no pointer seed.
  • Very light palette colours are darkened slightly on light themes so cells stay visible.