Backgrounds

Ferrofluid

A pool of magnetic fluid rendered as a per-pixel metaball field. A handful of blobs orbit on closed integer-harmonic paths and merge wherever their fields overlap. The cursor is a magnet held over the pool: the surface reaches toward it, and inside its influence the iso-edge erupts into the radial spike crown that makes ferrofluid unmistakable. Lighting is free, because the metaball gradient is analytic, so the same loop that sums the field also yields the surface normal for the specular sheen and the amethyst rim, with no extra field evaluations.

Install

bun add ogl

Then copy 2 files into your project:

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

Props

PropTypeDefaultDescription
blobsnumber5Metaball count in the ambient orbit.
speednumber1Orbit speed of the blob field.
cohesionnumber0.35Iso-surface softness — how eagerly blobs merge into one body.
spikesnumber0.7Needle amplitude where the cursor magnet touches the surface.
spikeFrequencynumber14Needles around the cursor — the tooth count of the spike crown.
magnetRadiusnumber0.35Cursor influence radius as a fraction of the pane.
sheennumber0.6Specular highlight strength on the fluid surface.
fluidColorstring (hex)"#17121f"Body of the fluid — near-black violet, read by its highlights.
accentColorstring (hex)"#c4b5fd"Rim light and specular tint on the iso edge.

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.
Morph
One shape smoothly turns into another shape, e.g. Dynamic Island.
Hardware acceleration
Animating transform and opacity lets the GPU keep motion smooth.

Related Components

Appears In