Ferrofluid shader preview: A glossy pool of magnetic fluid that bristles into spikes under the pointer.
ittybitty

Ferrofluid

A glossy pool of magnetic fluid that bristles into spikes under the pointer.

Code

Use as
Code view

Copy embed: paste into Webflow, Framer, Squarespace or any HTML · Copy for agent: paste into Cursor or Claude · Copy code: the files for your own build.

For your own build, add ferrofluid.js, ittybitty-shader.js, runtime.js and pointer.js next to this page. Highlighted values follow the controls.

<!-- Quickest: one element. Size it with CSS; it fills its box. -->
<script type="module" src="./ittybitty-shader.js"></script>
<ittybitty-shader effect="ferrofluid" style="width: 100%; height: 480px;"></ittybitty-shader>

<!-- Or with JavaScript, for full control: -->
<canvas id="ferrofluid" aria-hidden="true" style="width: 100%; height: 480px; display: block"></canvas>

<script type="module">
  import { ferrofluid } from './ferrofluid.js';

  const canvas = document.getElementById('ferrofluid');
  const effect = ferrofluid(canvas, {
    showBackground: true,
    speed: 0.5,
    spikes: 0.75,
    density: 0.5,
    strength: 0.8,
    reach: 0.7,
    interactive: true,
    responsiveness: 0.4,
    fluid: '#0a0a0c',
    mirror: 0,
    iridescence: 0.1,
    environment: 'studio',
    light: '#fff4e6',
    background: '#d6d3ce',
    // Performance
    dpr: 1.5,
    adaptive: true,
  });

  // Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>

Details

A pool of jet-black magnetic fluid on a studio floor. Bring the pointer near and the fluid heaps up and bristles into a crown of sharp cones, each leaning towards the magnet; move away and they melt back into the pool, and a click surges the field. With no pointer, a wandering magnet pulses the crown on its own. The surface mirrors a small invented studio, a neon room or a sunset sky.

Payload
11.1 KB brotli for ferrofluid.js, ittybitty-shader.js, runtime.js and pointer.js, measured at build time.
Resolution
Device pixel ratio capped at 1.5, so the spike tips stay sharp.
Frame rate
Display rate.
When unseen
Stops rendering when the canvas leaves the viewport or the tab is hidden, and resumes where it left off.
Reduced motion
Shows a single still frame. Controls still update it.
Layers
Up to five effects fuse into one shader and one draw call. Filters such as dithering and halftone process the layers beneath them.
Browsers
Any browser with WebGL2: Chrome and Edge 56+, Firefox 51+, Safari 15+.
Licence
MIT. Copy it, change it, ship it.