Voronoi Cells
NewCustomize
Color
Cell size72px
Edge2.00px
Bevel5.0px
Glow1.00
Fade0.45
Pulse1.00
Motion1.00
Speed1.0
Grain0.020
Installation
npx shadcn@latest add https://uibrik.com/r/voronoi-cells.jsonAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/voronoi-cells/voronoi-cells.tsx"use client"; import type { CSSProperties, ReactNode } from "react"; import { ShaderSurface } from "../_shader-background/ShaderSurface"; import { paletteOf, type ShadeStep } from "../_shader-background/shades"; // A field of cells, each grown from a point that wanders inside its own square, so the pattern // shifts like a living membrane without points ever crossing. Edges are found with Inigo Quilez's // exact border distance, so they stay one even width at any size. Each cell is a raised tile with a // bevelled rim, lit from the upper left, sitting in a narrow groove. Now and then a wave sweeps out // from a random spot and lights the cells it passes, whole cells at a time, as if a signal were // hopping through a network: light leaks up through the grooves around them and pools along their // rims. The cells under the pointer light up the same way, and a click sends a ring of its own. const SHADER = /* glsl */ ` uniform float u_cell; // cell size, css px uniform float u_edge; // groove width, css px uniform float u_bevel; // width of each tile's rim, css px uniform float u_fade; // how far the cells fade toward the edges uniform float u_glow; // how far lit cells glow along their edges uniform float u_pulse; // strength of the travelling waves uniform float u_motion; // how far each point wanders uniform float u_multi; // 1 when painting with a list of colours rather than shades of one vec2 hash22(vec2 p) {
Adds the files to
components/uibrik/voronoi-cells. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/voronoi-cells.Usage
import { VoronoiCells } from "@/components/uibrik/voronoi-cells/voronoi-cells";<VoronoiCells color="#4f63ff" cellSize={72} edge={2} bevel={5} glow={1} fade={0.45} waves pulse={1} motion={1} speed={1} grain={0.02} animate interactive> …</VoronoiCells>Props
VoronoiCells- color
- Type string
- "#4f63ff"
- Colour of the cells; drawn in shades of it.
- colors
- Type string[]
- ["#6a3df0","#2f8cff","#14b8a6","#e0479e"]
- Hex colours, 2 to 6, spread across the field in drifting patches. Overrides color.
- cellSize
- Type number
- 72
- Cell size.
- edge
- Type number
- 2
- Width of the groove between cells.
- bevel
- Type number
- 5
- Width of each cell's bevelled rim; 0 is flat.
- glow
- Type number
- 1
- How far light from a lit cell's grooves spreads over it; 0 turns the glow off.
- fade
- Type number
- 0.45
- How far the cells fade toward the edges; 0 keeps them even.
- waves
- Type boolean
- true
- Send waves sweeping across the cells now and then; off leaves only the pointer and clicks.
- pulse
- Type number
- 1
- Strength of the waves that sweep across the cells; 0 turns them off.
- motion
- Type number
- 1
- How far each cell's point wanders; 0 holds the pattern still.
- speed
- Type number
- 1
- Animation speed; 1 is the designed pace.
- grain
- Type number
- 0.02
- Film grain strength.
- animate
- Type boolean
- true
- Move on its own. Off draws one still frame.
- interactive
- Type boolean
- true
- Light the cells under the pointer; a click sends a ring.
- children
- Type ReactNode
- –
- Content shown on top of the background.
- className
- Type string
- –
- Classes for the box; it fills whatever size you give it.