# Fluid Mosaic

**Group:** Galleries and grids  
**Recording:** [https://s4xw77gvirailb62.public.blob.vercel-storage.com/lab/fluid-mosaic.mp4](https://s4xw77gvirailb62.public.blob.vercel-storage.com/lab/fluid-mosaic.mp4)  
**Source:** [https://ui.aryank.space/components/fluid-mosaic](https://ui.aryank.space/components/fluid-mosaic)  
**Human:** https://blankinterfaces.com/lab/fluid-mosaic

---

## What it is

An editorial bento grid whose rows and columns are sized by a gaussian lens centered on the cursor, so the tile you approach swells while its neighbours give up their space. Photographs counter-drift inside their tiles, captions lift on hover, and the area map re-cuts itself for one to twelve items and again on narrow screens. No dependencies.

## Behaviour

### A gaussian lens sizes the tracks, not the tiles

Every column and row gets a weight of 1 + e^(-d^2/2r^2) x strength, where d is the distance from the cursor to that track's centre. Nothing is animated per tile: the whole layout is two lists of fr values, so a swelling tile automatically takes its space from its neighbours and the gaps stay exact.

### A 0.18fr floor stops far tracks collapsing

At high strength the untouched tracks would shrink until their images turned into slivers. Clamping each weight to a minimum keeps the grid legible at the far edge no matter how hard the lens pulls.

### The cursor is eased, the tracks are written raw

A rAF loop moves the pointer toward its target by a fixed fraction each frame, then writes gridTemplateColumns and gridTemplateRows imperatively. React never re-renders for motion, so the loop costs two style writes a frame regardless of tile count.

### Images are oversized by the parallax distance

Each photograph is inset by -parallax on all sides and drifts against the cursor, so the counter-movement never exposes an edge. That drift is what makes a growing tile feel like it reveals more of the picture instead of stretching one crop.

### The area map is chosen by item count

One table of grid-template-areas per count from one to twelve, each keeping a two-by-two hero in the top left. A ResizeObserver on the root swaps in a one or two column map below the breakpoint, so the component reflows on its own width rather than the viewport's.

---

[View all content](https://blankinterfaces.com/sitemap.md)
