Backgrounds

Flock Field

A murmuration of hundreds of boids wheeling as one — separation, alignment, and cohesion resolved every frame through a spatial hash for the crowd, banking toward or scattering from your cursor, smeared into long trails of amethyst and cyan as the flock folds across the dark.

Install

# FlockField needs no npm packages

Then copy 2 files into your project:

  • components/registry/flock-field/flock-field.tsx
  • hooks/use-animation-loop.ts

Props

PropTypeDefaultDescription
countnumber300Number of boids in the flock. Spatial-hash lookup keeps it near-linear.
speednumber2.5Maximum boid speed, px per frame.
separationnumber1.2Weight of steering away from close neighbors.
alignmentnumber1Weight of matching neighbors' heading.
cohesionnumber1Weight of steering toward the neighbor center of mass.
neighborRadiusnumber60How far a boid sees neighbors; sets the spatial-hash cell size.
separationRadiusnumber24Distance under which boids actively push apart.
cursorMode"attract" | "repel" | "off""repel"Whether the cursor draws the flock in, scatters it, or is ignored.
cursorForcenumber1.5Strength of the cursor's pull or push.
cursorRadiusnumber160Radius of the cursor's influence.
trailnumber0.85Motion-trail persistence — 0 is crisp, high smears long tails.
color1string (hex)"#a855f7"Slow-boid color.
color2string (hex)"#22d3ee"Fast-boid color — boids grade between the two by speed.

What It Demonstrates

Loop
An animation that repeats, a set number of times or infinitely.
Idle animation
Subtle motion that plays while an element is just sitting there, waiting to be interacted with.
Hover effect
Visual change when the cursor moves over an element.
Follow-through
Parts of an element keep moving and settle slightly after the main motion stops, adding weight.

Related Components

Appears In