Expanse

An endless wall of cards in staggered columns. Drag, fling or scroll it in any direction and it keeps going, wrapping with no seams, with a soft lens that eases the edges away.

Drag, scroll or use the arrow keys to look around. Enter opens the card in the middle.

Props
Aspect
Column width280
Gap16
Stagger0.50
Lens0.50
Friction0.95
Drift0
Radius14
Fade80

Installation

pnpm dlx shadcn@latest add @breeze/expanse

Usage

import { Expanse } from "@/components/breeze/expanse"

Give it a handful of images and a size. A short list is plenty: it repeats forever.

const items = [
  { src: "/work/studio.webp", alt: "Studio site", href: "/work/studio" },
  { src: "/work/app.webp", alt: "App dashboard", aspect: 3 / 4 },
  "/work/poster.webp",
  // ...
]

<section className="relative h-[80vh]">
  <Expanse items={items} className="absolute inset-0 h-full w-full" />
</section>

Props

PropTypeDefaultDescription
items(string | { src, alt?, href?, aspect? } | { node, aspect? } | ReactElement)[]requiredImage URLs, images with details, or any element to show in a card ({ node, aspect } gives it a shape)
columnWidthnumber280Width of a column in px. Phones use slimmer columns, about two across
gapnumber16Space between cards in px
staggernumber0.5How far columns shift against each other, as a share of a card's height
aspect"mixed" | "landscape" | "square" | "portrait" | number"mixed"Card shape. mixed uses each item's own aspect, or a varied set of shapes
lensnumber0.5How much cards shrink and dim towards the edges. 0 turns the lens off
frictionnumber0.95How long a fling glides, from 0 (stops dead) to 0.99 (glides for ages)
driftnumber0Slow auto-pan in px per second. 0 keeps it still
radiusnumber14Card corner radius in px
fadenumber80Width of the fade into the page at the edges in px. 0 turns it off
fadeColorstring"var(--background)"Colour the edges fade into. Set it to match if the wall sits on another colour
labelstring"Gallery"Accessible name for the wall
captureScrollbooleantrueThe wheel and touch pan the wall. false lets the page scroll past it
onItemClick(item, index) => voidCalled when a card is clicked or opened with Enter, never at the end of a drag
childrenReactNodeCentred over the wall. It ignores the pointer, so dragging through it still works

The wall is columns that go on forever in both directions. Each column runs through all your items in its own order and starts over, and the columns sit at uneven heights, so it never lines up into a grid and never shows a seam, a gap or a jump, however far you go. Grab it with a mouse, a finger or a pen and let go to glide to a smooth stop; a trackpad or a wheel pans it too, and once it has focus the arrow keys move it and Enter opens the card in the middle. A press that doesn't move is a click, so cards with an href work as links and onItemClick only fires for real clicks. Towards the edges the cards ease down a touch in size and light, like a soft lens, and fade into your page background, in light and dark. The fade is a still veil in fadeColor rather than a mask, which keeps dragging cheap; if the wall sits on something other than your page background, set fadeColor to match it, or set fade={0}. Cards mount a little before they scroll into view, so images are ready when they arrive, and one animation frame moves them, without re-rendering anything. It sleeps when nothing is moving, when it's off-screen or when the tab is hidden. With reduced motion you can still drag it, without the glide, the lens or the drift.

Anything you put in children floats in the middle and lets drags pass through it. To make something in it clickable, give that element pointer-events-auto.

Other props such as id, style or data-* go on the wall's root element.

Scrolling past it

By default the wall takes the wheel and every touch swipe, which suits a full-screen gallery. If it sits in a long page, pass captureScroll={false}: the wheel and vertical swipes then scroll the page, and you move the wall by dragging (sideways on touch) or with the arrow keys.

<Expanse items={items} captureScroll={false} className="h-[60vh] w-full" />

Cards that aren't images

Any element can fill a card. Pass it as { node, aspect } to give the card its own shape when aspect is "mixed":

const items = [
  { node: <QuoteCard />, aspect: 4 / 5 },
  { node: <StatCard />, aspect: 16 / 10 },
  "/work/poster.webp",
]

Examples

With a headline

Drag, scroll or use the arrow keys to look around. Enter opens the card in the middle.

Made with Breeze

Drag anywhere to look around

Drifting, all one shape

Drag, scroll or use the arrow keys to look around. Enter opens the card in the middle.