Isometric Wall
Faded picture cards slide slowly along diagonal columns on a tilted floor, and the one you hover lifts gently. Use it behind a hero with one short headline.
Components that movemade for humans again
Copy animated React components into your app. Every one is tuned by hand, down to the easing curve.
Loved by 100k+ humans
npx shadcn@latest add https://impeccableui.vercel.app/r/isometric-wall.jsonRun it in a project set up with shadcn. No other packages needed. Or open and copy the file into components/ui/isometric-wall.tsx.
Prompts
Paste one into Claude Code, Cursor or any AI coding tool. Install adds this exact background and asks only which section it goes behind. Blend asks five short questions (where, which pictures, how calm, how fast and the corners), then fits it to your brand without changing how it moves.
# Isometric Wall
A 1-file React component from Impeccable. Add it to this project so it works and looks exactly like the source below, in the one place I choose, and change nothing else.
Faded picture cards lie on a tilted floor, fill the whole section in diagonal columns, and every column slides slowly along itself; the card under the mouse lifts gently with a softer shadow. It sits behind the content and never catches a click.
## Before you build: one question
Look through this project first: its landing and hero sections, its root layout, which sections have plain, empty backgrounds, and the images it already has (in `public/`, an assets folder or a CMS). Then ask me this in one message and wait for my answer:
- **Where should it go, and which pictures should it show?** Suggest the 1–3 sections it fits best behind (for example the hero), or the whole page. For a section, keep its content and wrap it in the wall. For the whole page, it goes once in the root layout, fixed to the screen. For the pictures, suggest 8–16 of my own images that fit, or offer placeholders I can swap later.
*Why: the wall is calm but full of pictures, so it suits a hero with one short headline, and it can't show anything without pictures.*
Ask nothing else. If I say *skip*, use the best suggestion.
## Keep it as it is
The tilted floor, the 7, 5 or 3 diagonal columns, the diagonal columns that slide slowly along themselves and never stop, the gentle 8px lift with its softer shadow, the faded pictures (45% light, 18% dark) and the soft edge fade are the design. Keep them exactly as in the source, with the default props. If something doesn't fit my project, tell me instead of changing it.
- Add only the component file, the pictures and the one place I picked. If it wraps an existing section, keep that section's content and spacing. Don't add packages, change other files, or restyle anything.
- Don't add the demo parts from the Impeccable website: the Impeccable UI hero (its heading, the button, the stars, the "Loved by" line and the faces), the soft clearing behind it and the demo photos.
## Fastest path
If this project has a `components.json` (shadcn), run `npx shadcn@latest add https://impeccableui.vercel.app/r/isometric-wall.json`.
If the command succeeds, only fix import paths to match this project and skip ahead. If it fails or there is no `components.json`, build it by hand as below.
## Build it
- Stack: React 18 or 19 with TypeScript. No other packages: the floor is plain elements turned with one CSS transform, and the drift is one Web Animations call.
- JavaScript project? Name the file `isometric-wall.jsx` and remove the type annotations; nothing else changes.
- Create this file, in this project's usual place for components:
- `components/ui/isometric-wall.tsx`
- Keep these exports and their names: `IsometricWall`, `IsometricWallProps`.
- Keep `"use client"` at the top in Next.js App Router projects. In other setups it is harmless.
- Keep the tuning values at the top exactly as written: `TILT`, `TURN`, `ASPECT`, `GAP`, `LOOP_ROWS`, `LIFT_MS`, `DROP_MS`, `LIFT_EASE`, `DROP_EASE`, `ENTER_MS`, `ENTER_SPREAD_MS`, `ENTER_EASE`, `READY_WAIT_MS`, `FADE`, `FADE_MIN`, `PATTERN`, the `EDGE_MASK` and the `CSS` block. They are the design.
- Keep the fallbacks: with `prefers-reduced-motion: reduce` the wall stands still, the cards only fade in and a hovered card only deepens its shadow. Touch screens get the drift without the lift. Off screen the drift pauses, and the pictures load only when the wall comes within 300px of the screen.
- Keep the wall out of the way: `pointer-events: none`, `user-select: none` and `aria-hidden` on its layer, and `alt=""` on its pictures. It must never catch a click, a text selection or a screen reader.
- Pictures: use small files, about 480px wide (WebP if the project can), because up to 16 of them load at once. They are cropped to 3:2 cards, so landscape photos work best.
## Use it
```tsx
"use client";
import { IsometricWall } from "@/components/ui/isometric-wall";
const PHOTOS = ["/wall/01.webp", "/wall/02.webp", "/wall/03.webp" /* up to 16 */];
// Behind one section: wrap its content and give it a size.
export function Hero() {
return (
<IsometricWall images={PHOTOS} className="flex min-h-[640px] flex-col items-center justify-center gap-6 px-6 text-center">
<h1>Components that move</h1>
<a href="/docs">Browse components</a>
</IsometricWall>
);
}
// Behind the whole page: once in the root layout, empty, fixed to the screen.
<IsometricWall images={PHOTOS} className="fixed inset-0 -z-10" />
```
- It is a `<div>` and takes every div prop. `className` and `style` go on the box: give it a size (or let it fill its parent). The floor is the page color, so it needs no background.
- Everything inside it sits above the wall and works as normal. Keep the section's own tag and landmarks (`<section>`, `<main>`) inside it, or wrap the wall inside the section.
- If the headline sits on busy pictures, a soft page-colored glow behind the text (a radial gradient from the page color to transparent) keeps it readable. Add it in my section, never in the component.
## How the wall works
Read this before you touch anything, so you know what the code does and why it must stay as it is.
1. **The floor.** All the cards sit on one flat layer that is tipped back 56° and turned 45°, with no perspective, like an isometric drawing of prints on a table. The cards are 3:2, with a gap of 10% of a card's width between them.
2. **The columns.** The cards stand in columns along the floor's depth, so on screen each column runs diagonally, down and to the right. Every other column sits half a card further along, like bricks. The card width comes from the box: about 7 columns on a wide box, 5 from 640px to 1024px, 3 below 640px (or `columns`).
3. **The drift.** Every column slides along itself, up and to the left, `speed` px a second (12), in one linear compositor animation on the floor. After 4 cards it is back where it started, picture for picture, because the pictures follow a fixed 4 x 4 pattern (`PATTERN`). So it loops forever with no seam and no script running each frame. It fills the box plus one loop and one card all round, and no more.
4. **The lift.** A hovered card rises `lift` px (8) straight up the screen in 320ms with a quick start and a long soft finish, and settles back in 480ms, a touch slower. Its shadow sits on the floor and crossfades from a close, small shadow to a wider, softer one further out, so the gap under the card reads as height. The shadow starts from a smaller box under the card, so a lifted card never shows a hard shadow edge. The drift never stops: the hovered card is worked out from the pointer and the current drift, so when a card drifts out from under a still mouse the next one takes over. Hover only runs for a real mouse.
5. **The look.** The floor is the page color (`--background`, else `--bg`), and each card is filled with it, so the pictures can be faded: 45% in light mode and 18% in dark mode (`opacity`, `darkOpacity`), with a hairline edge so dark cards keep their shape. Dark mode follows a `.dark` class or `data-theme="dark"` on any parent. The edges fade out through a mask (12% of the box's short side), measured from the nearest edge so the corners never fade twice.
6. **Coming in.** When the pictures are ready (or after 1.5s at most) the cards fade in and settle onto the floor over 900ms, from the middle outward over 600ms.
## Check
- It type-checks and the page renders with no console errors.
- The cards come in from the middle outward, then every column slides up and to the left along its diagonal, about 12px a second, without ever jumping. Resting the mouse on a card lifts it about 8px with a softer, wider shadow; the drift keeps going, and it settles back when the mouse leaves. Text on top can still be selected and every button and link on top still works.
- It looks right in light and dark mode (check both): pictures clearly faded in light, very quiet in dark, and the edges fade out evenly into the page.
- On a phone the wall drifts with 3 columns, nothing lifts, and the page still scrolls normally with no sideways scroll.
- With `prefers-reduced-motion: reduce`, the wall stands still, the cards only fade in, and a hovered card only deepens its shadow.
- Nothing else on the site looks or behaves differently.
- Finish with a short report: the files you added or changed, where it's placed, and every place where you had to do something differently from the source, and why.
## Source
The reference implementation. Copy it as-is, then apply only the changes listed above.
### `components/ui/isometric-wall.tsx`
```tsx
"use client";
/**
* Isometric Wall, from Impeccable.
*
* A calm background of picture cards lying on a tilted floor, seen from above
* at an angle, like prints spread on a table. The cards stand in diagonal
* columns that fill the whole box, and every column slides slowly along itself,
* up and to the left, forever. Hover a card and it lifts a
* little off the floor while its shadow grows wider and softer; move away and
* it settles back. The drift never stops for it.
*
* The pictures are faded (45% in light mode, 18% in dark) so the wall stays
* quiet behind your headline. The edges fade out through a mask, so it blends
* into any page color. It sits behind whatever you put inside it, never catches
* a click, and is hidden from screen readers.
*
* No packages. The floor is one flat layer turned in 3D, and the drift is one
* compositor animation, so the page's own work never makes it stutter. Pictures
* load only when the wall comes near the screen; it pauses off screen.
*/
import { useEffect, useMemo, useRef, useState, type CSSProperties, type HTMLAttributes, type ReactNode } from "react";
export type IsometricWallProps = HTMLAttributes<HTMLDivElement> & {
/** The pictures. Any size: each one is cropped to a 3:2 card. 16 looks best; fewer repeat more often. */
images: string[];
/** Columns across the box. Default: 7 on wide boxes, 5 from 640px down to 1024px, 3 below 640px. */
columns?: number;
/** How fast the columns slide along their diagonal, in px a second. 0 holds it still. */
speed?: number;
/** How far a hovered card lifts, in px on screen. */
lift?: number;
/** How strong the pictures are in light mode, 0 to 1. */
opacity?: number;
/** How strong the pictures are in dark mode, 0 to 1. */
darkOpacity?: number;
/** Card corners, in px. */
radius?: number;
/** Your content. It sits above the wall and works as normal. */
children?: ReactNode;
};
/* ---------- tuning (the design: keep as written) ---------- */
const TILT = 56; // deg: how far the floor tips back (0 = flat to you, 90 = edge on)
const TURN = 45; // deg: how far the floor turns
const ASPECT = 1.5; // card width / height (3:2)
const GAP = 0.1; // space between cards, as a share of a card's width
const LOOP_ROWS = 4; // the drift repeats every this many cards along a column (pictures follow a 4 x 4 pattern)
const LIFT_MS = 320; // a card rises over this long
const DROP_MS = 480; // and settles back over this long, gentler
const LIFT_EASE = "cubic-bezier(.22,1,.36,1)"; // quick start, long soft finish
const DROP_EASE = "cubic-bezier(.33,1,.68,1)"; // a softer landing
const ENTER_MS = 900; // each card fades and settles onto the floor over this long
const ENTER_SPREAD_MS = 600; // cards far from the middle arrive this much later
const ENTER_EASE = "cubic-bezier(.16,1,.3,1)";
const READY_WAIT_MS = 1500; // the cards come in when the pictures are ready, or after this long at most
const FADE = 0.12; // the edge fade, as a share of the box's short side
const FADE_MIN = 28; // px: never a thinner fade than this
/** Which picture each card gets: a fixed shuffle of a 4 x 4 pattern, so no two neighbours ever match. */
const PATTERN = [9, 2, 14, 5, 12, 7, 0, 11, 3, 15, 8, 1, 6, 10, 4, 13];
/**
* The edge fade: one even fade along every side, measured from the nearest edge, so the
* corners fade exactly as much as the sides and never twice. Nine mask pieces that don't
* overlap: the solid middle, four side strips, four round corners. --iiw-f is its width.
*/
const F = "var(--iiw-f)";
const RAMP = "#000, rgba(0,0,0,.6) 45%, transparent";
const EDGE_MASK = [
`linear-gradient(#000,#000) calc(${F} - 1px) calc(${F} - 1px) / calc(100% - 2 * ${F} + 2px) calc(100% - 2 * ${F} + 2px) no-repeat`,
`linear-gradient(to top, ${RAMP}) ${F} 0 / calc(100% - 2 * ${F}) ${F} no-repeat`,
`linear-gradient(to bottom, ${RAMP}) ${F} 100% / calc(100% - 2 * ${F}) ${F} no-repeat`,
`linear-gradient(to left, ${RAMP}) 0 ${F} / ${F} calc(100% - 2 * ${F}) no-repeat`,
`linear-gradient(to right, ${RAMP}) 100% ${F} / ${F} calc(100% - 2 * ${F}) no-repeat`,
`radial-gradient(circle ${F} at 100% 100%, ${RAMP}) 0 0 / ${F} ${F} no-repeat`,
`radial-gradient(circle ${F} at 0 100%, ${RAMP}) 100% 0 / ${F} ${F} no-repeat`,
`radial-gradient(circle ${F} at 100% 0, ${RAMP}) 0 100% / ${F} ${F} no-repeat`,
`radial-gradient(circle ${F} at 0 0, ${RAMP}) 100% 100% / ${F} ${F} no-repeat`,
].join(", ");
const CSS = `
:where(.iiw) { position: relative; isolation: isolate; overflow: hidden;
--iiw-floor: var(--background, var(--bg, Canvas));
--iiw-o: var(--iiw-o-light); --iiw-ink: 24 22 40; --iiw-rest-a: .16; --iiw-up-a: .2; --iiw-ring: rgb(0 0 0 / .05); }
:is(.dark, [data-theme="dark"]) .iiw { --iiw-o: var(--iiw-o-dark); --iiw-ink: 0 0 0; --iiw-rest-a: .5; --iiw-up-a: .45; --iiw-ring: rgb(255 255 255 / .07); }
.iiw-layer { position: absolute; left: 0; top: 0; width: var(--iiw-lw, 100%); height: var(--iiw-lh, 100%); z-index: -1; overflow: hidden; pointer-events: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
-webkit-mask: ${EDGE_MASK}; mask: ${EDGE_MASK}; }
.iiw-plane { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: rotateX(${TILT}deg) rotateZ(-${TURN}deg); }
.iiw-track { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.iiw-at { position: absolute; left: 0; top: 0; }
.iiw-sh, .iiw-card { position: absolute; left: 0; top: 0; width: var(--iiw-w); height: var(--iiw-h); }
.iiw-sh::before, .iiw-sh::after { content: ""; position: absolute; inset: var(--iiw-k); border-radius: var(--iiw-rk);
transition: opacity ${DROP_MS}ms ${DROP_EASE}; }
.iiw-sh::before { box-shadow: var(--iiw-rest-x) var(--iiw-rest-y) 10px calc(var(--iiw-k) - 2px) rgb(var(--iiw-ink) / var(--iiw-rest-a)); }
.iiw-sh::after { opacity: 0; box-shadow: var(--iiw-up-x) var(--iiw-up-y) 30px calc(var(--iiw-k) - 5px) rgb(var(--iiw-ink) / var(--iiw-up-a)); }
.iiw-sh[data-up]::before { opacity: 0; transition: opacity ${LIFT_MS}ms ${LIFT_EASE}; }
.iiw-sh[data-up]::after { opacity: 1; transition: opacity ${LIFT_MS}ms ${LIFT_EASE}; }
.iiw-card { transition: transform ${DROP_MS}ms ${DROP_EASE}; }
.iiw-card[data-up] { transform: translate(var(--iiw-lift-x), var(--iiw-lift-y)); transition: transform ${LIFT_MS}ms ${LIFT_EASE}; }
.iiw-face { width: 100%; height: 100%; overflow: hidden; border-radius: var(--iiw-r); background: var(--iiw-floor); box-shadow: inset 0 0 0 1px var(--iiw-ring); }
.iiw-face img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; opacity: var(--iiw-o); pointer-events: none;
user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
.iiw-in { opacity: 0; transform: translate(var(--iiw-drop-x), var(--iiw-drop-y));
transition: opacity ${ENTER_MS}ms ${ENTER_EASE} var(--iiw-d), transform ${ENTER_MS}ms ${ENTER_EASE} var(--iiw-d); }
.iiw-in-sh { opacity: 0; transition: opacity ${ENTER_MS}ms ${ENTER_EASE} var(--iiw-d); }
.iiw[data-in] .iiw-in, .iiw[data-in] .iiw-in-sh { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
.iiw-card[data-up] { transform: none; }
.iiw-in { transform: none; transition-duration: 400ms; transition-delay: 0ms; }
}`;
/* ---------- geometry ---------- */
const rad = (d: number) => (d * Math.PI) / 180;
const COS_T = Math.cos(rad(TURN));
const SIN_T = Math.sin(rad(TURN));
const COS_A = Math.cos(rad(TILT));
const num = (v: unknown, fallback: number, min: number, max: number) =>
typeof v === "number" && Number.isFinite(v) ? Math.min(max, Math.max(min, v)) : fallback;
const mod = (a: number, n: number) => ((a % n) + n) % n;
/** Floor point to screen, from the middle of the box (the floor has no perspective, like a real isometric drawing). */
const toScreen = (x: number, y: number) => [x * COS_T + y * SIN_T, (-x * SIN_T + y * COS_T) * COS_A] as const;
/** Screen point (from the middle of the box) back to the floor. */
const toFloor = (sx: number, sy: number) => {
const y1 = sy / COS_A;
return [sx * COS_T - y1 * SIN_T, sx * SIN_T + y1 * COS_T] as const;
};
type Layout = {
w: number; // card width on the floor
h: number; // card height
pitch: number; // one column step on the floor (across the columns)
row: number; // one card step along a column
loop: number; // px on screen the drift travels before it repeats
cells: { c: number; r: number; x: number; y: number; d: number }[];
};
/** Every other column sits half a card further along, like the cards in a brick wall. */
const colOffset = (c: number, row: number) => (mod(c, 2) ? row / 2 : 0);
function layout(boxW: number, boxH: number, cols: number): Layout {
// The cards stand in columns along the floor's depth, which run diagonally down the screen.
const pitch = boxW / (cols * COS_T);
const w = pitch / (1 + GAP);
const h = w / ASPECT;
const row = h + (pitch - w);
const travel = LOOP_ROWS * row; // the floor slides this far along the columns in one loop
const loop = travel * Math.hypot(SIN_T, COS_T * COS_A);
// Everything the box can show at any moment of one loop, plus one card all round.
const pad = w;
const left = -boxW / 2 - pad, right = boxW / 2 + pad, top = -boxH / 2 - pad, bottom = boxH / 2 + pad;
const corners = [toFloor(left, top), toFloor(right, top), toFloor(left, bottom), toFloor(right, bottom)];
const xs = corners.map(([x]) => x), ys = corners.map(([, y]) => y);
const c0 = Math.floor(Math.min(...xs) / pitch) - 1, c1 = Math.ceil(Math.max(...xs) / pitch) + 1;
const r0 = Math.floor(Math.min(...ys) / row) - 2, r1 = Math.ceil((Math.max(...ys) + travel) / row) + 1;
const inside = (sx: number, sy: number) => sx >= left && sx <= right && sy >= top && sy <= bottom;
const cells: Layout["cells"] = [];
const reach = Math.hypot(boxW / 2, boxH / 2) || 1;
for (let c = c0; c <= c1; c++) {
for (let r = r0; r <= r1; r++) {
const x = c * pitch, y = r * row + colOffset(c, row);
let seen = false;
for (let k = 0; k <= 8 && !seen; k++) {
const [sx, sy] = toScreen(x + w / 2, y + h / 2 - (travel * k) / 8);
seen = inside(sx, sy);
}
if (!seen) continue;
// Cards nearest the middle of the box arrive first.
const [sx, sy] = toScreen(x + w / 2, y + h / 2);
cells.push({ c, r, x, y, d: Math.min(1, Math.hypot(sx, sy) / reach) });
}
}
return { w, h, pitch, row, loop, cells };
}
/** How far through one loop a drift animation is, from 0 to 1. */
function progressOf(a: Animation | null) {
if (!a || a.currentTime == null) return 0;
const d = Number(a.effect?.getTiming().duration) || 1;
return (Number(a.currentTime) % d) / d;
}
const autoColumns = (boxW: number) => (boxW < 640 ? 3 : boxW < 1024 ? 5 : 7);
/** "12px" for a CSS custom property, rounded so the style text stays short. */
const px = (n: number) => `${Math.round(n * 100) / 100}px`;
/* ---------- the component ---------- */
export function IsometricWall({
images,
columns,
speed = 12,
lift = 8,
opacity = 0.45,
darkOpacity = 0.18,
radius = 14,
className,
style,
children,
...rest
}: IsometricWallProps) {
const rootRef = useRef<HTMLDivElement>(null);
const trackRef = useRef<HTMLDivElement>(null);
const [size, setSize] = useState<{ w: number; h: number } | null>(null);
const [near, setNear] = useState(false); // close enough to the screen to load pictures
const [ready, setReady] = useState(false); // pictures ready: the cards come in
const pics = useMemo(() => (Array.isArray(images) ? images.filter((s) => typeof s === "string" && s) : []), [images]);
const cols = Math.round(num(columns, size ? autoColumns(size.w) : 7, 1, 24));
const lay = useMemo(() => (size && size.w > 0 && size.h > 0 ? layout(size.w, size.h, cols) : null), [size, cols]);
const speedPx = num(speed, 12, 0, 400);
const liftPx = num(lift, 8, 0, 80);
// Measure the box, and again whenever it changes size.
useEffect(() => {
const el = rootRef.current;
if (!el) return;
// Layout size, not the size on screen: a scaled parent (a zoomed-out preview)
// must not shrink the wall, or it would cover only part of the box.
const measure = () => {
const w = el.offsetWidth, h = el.offsetHeight;
setSize((s) => (s && Math.abs(s.w - w) < 1 && Math.abs(s.h - h) < 1 ? s : { w, h }));
};
measure();
const ro = new ResizeObserver(measure);
ro.observe(el);
return () => ro.disconnect();
}, []);
// Load the pictures only once the wall is near the screen.
useEffect(() => {
const el = rootRef.current;
if (!el || near) return;
const io = new IntersectionObserver((e) => e.some((x) => x.isIntersecting) && setNear(true), { rootMargin: "300px" });
io.observe(el);
return () => io.disconnect();
}, [near]);
// When the pictures are decoded (or after a short wait at most), bring the cards in.
useEffect(() => {
if (!near || ready) return;
let done = false;
const go = () => !done && ((done = true), setReady(true));
const timer = window.setTimeout(go, READY_WAIT_MS);
Promise.allSettled(
pics.map((src) => {
const img = new Image();
img.src = src;
return img.decode();
}),
).then(go);
return () => {
done = true;
window.clearTimeout(timer);
};
}, [near, ready, pics]);
// The drift (one compositor animation) and the hover (worked out from the pointer, so it
// also follows a card that drifts away under a still mouse).
useEffect(() => {
const root = rootRef.current, track = trackRef.current;
if (!root || !track || !lay) return;
const reduce = matchMedia("(prefers-reduced-motion: reduce)");
const fine = matchMedia("(hover: hover) and (pointer: fine)");
// The drift: every column slides along itself, up and to the left, by LOOP_ROWS cards,
// then starts again on a picture-for-picture match.
const dx = 0, dy = -LOOP_ROWS * lay.row;
let anim: Animation | null = null;
let visible = true;
const startDrift = () => {
const progress = progressOf(anim);
anim?.cancel();
anim = null;
if (reduce.matches || speedPx <= 0) return;
const duration = (lay.loop / speedPx) * 1000;
anim = track.animate([{ transform: "translate(0px, 0px)" }, { transform: `translate(${dx}px, ${dy}px)` }], {
duration,
iterations: Infinity,
easing: "linear",
});
anim.currentTime = progress * duration;
if (!visible) anim.pause();
};
startDrift();
const io = new IntersectionObserver((e) => {
visible = e.some((x) => x.isIntersecting);
if (visible) anim?.play();
else anim?.pause();
});
io.observe(root);
// The hover.
const cards = new Map<string, [HTMLElement, HTMLElement]>();
const sh = track.querySelectorAll<HTMLElement>(".iiw-sh");
track.querySelectorAll<HTMLElement>(".iiw-card").forEach((el, i) => cards.set(el.dataset.key!, [el, sh[i]]));
let up: [HTMLElement, HTMLElement] | null = null;
const setUp = (next: [HTMLElement, HTMLElement] | null) => {
if (next === up) return;
up?.forEach((el) => el.removeAttribute("data-up"));
next?.forEach((el) => el.setAttribute("data-up", ""));
up = next;
};
let px0 = 0, py0 = 0, inside = false, raf = 0;
const find = () => {
const r = root.getBoundingClientRect();
// Back to the wall's own pixels, in case a parent scales it.
const k = root.offsetWidth ? r.width / root.offsetWidth : 1;
const sx = (px0 - r.left) / k, sy = (py0 - r.top) / k;
const bw = r.width / k, bh = r.height / k;
if (sx < 0 || sy < 0 || sx > bw || sy > bh) {
inside = false;
return setUp(null);
}
// Where the drift has carried the floor right now.
const t = progressOf(anim);
const ox = dx * t, oy = dy * t;
const [fx0, fy0] = toFloor(sx - bw / 2, sy - bh / 2);
const fx = fx0 - ox, fy = fy0 - oy;
const c = Math.floor(fx / lay.pitch);
if (fx - c * lay.pitch > lay.w) return setUp(null); // in the gap between columns
const along = fy - colOffset(c, lay.row);
const row = Math.floor(along / lay.row);
if (along - row * lay.row > lay.h) return setUp(null); // in the gap between cards
setUp(cards.get(`${c},${row}`) ?? null);
};
const loop = () => {
find();
raf = inside && anim && anim.playState === "running" ? requestAnimationFrame(loop) : 0;
};
const onMove = (e: PointerEvent) => {
if (e.pointerType !== "mouse" || !fine.matches) return;
px0 = e.clientX;
py0 = e.clientY;
const r = root.getBoundingClientRect();
const now = px0 >= r.left && px0 <= r.right && py0 >= r.top && py0 <= r.bottom;
if (!now) {
inside = false;
return setUp(null);
}
inside = true;
find();
if (!raf && anim && anim.playState === "running") raf = requestAnimationFrame(loop);
};
const onLeave = () => {
inside = false;
setUp(null);
};
window.addEventListener("pointermove", onMove, { passive: true });
document.documentElement.addEventListener("pointerleave", onLeave);
window.addEventListener("blur", onLeave);
// A page that scrolls under a still mouse moves the cards too.
const onScroll = () => inside && find();
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
reduce.addEventListener("change", startDrift);
return () => {
anim?.cancel();
io.disconnect();
cancelAnimationFrame(raf);
setUp(null);
window.removeEventListener("pointermove", onMove);
document.documentElement.removeEventListener("pointerleave", onLeave);
window.removeEventListener("blur", onLeave);
window.removeEventListener("scroll", onScroll, { capture: true });
reduce.removeEventListener("change", startDrift);
};
}, [lay, speedPx]);
// Everything the cards share, as CSS variables on the box.
const vars = useMemo(() => {
const v: Record<string, string> = {
"--iiw-o-light": String(num(opacity, 0.45, 0, 1)),
"--iiw-o-dark": String(num(darkOpacity, 0.18, 0, 1)),
};
if (!lay || !size) return v;
const r = Math.min(num(radius, 14, 0, 200), lay.h / 2);
const k = Math.max(4, Math.min(lay.w, lay.h) * 0.22); // the shadow starts from a smaller box under the card, so a lifted card never shows its edge
const down = (d: number) => [(-SIN_T * d) / COS_A, (COS_T * d) / COS_A]; // floor offset that shows as d px straight down the screen
const [rx, ry] = down(3);
const [ux, uy] = down(12);
const [lx, ly] = down(-liftPx);
const [ex, ey] = down(-Math.max(liftPx, 6) * 1.5);
Object.assign(v, {
"--iiw-lw": `${Math.ceil(size.w)}px`,
"--iiw-lh": `${Math.ceil(size.h)}px`,
"--iiw-w": px(lay.w),
"--iiw-h": px(lay.h),
"--iiw-r": px(r),
"--iiw-k": px(k),
"--iiw-rk": px(Math.max(0, r - k)),
"--iiw-rest-x": px(rx),
"--iiw-rest-y": px(ry),
"--iiw-up-x": px(ux),
"--iiw-up-y": px(uy),
"--iiw-lift-x": px(lx),
"--iiw-lift-y": px(ly),
"--iiw-drop-x": px(ex),
"--iiw-drop-y": px(ey),
// Whole pixels, so the nine mask pieces meet exactly and never leave a hairline seam.
"--iiw-f": `${Math.round(Math.max(FADE_MIN, Math.min(size.w, size.h) * FADE))}px`,
});
return v;
}, [lay, size, opacity, darkOpacity, radius, liftPx]);
const cells = lay && pics.length ? lay.cells : [];
const picOf = (c: number, r: number) => pics[PATTERN[mod(c, 4) * 4 + mod(r, LOOP_ROWS)] % pics.length];
const at = (x: number, y: number): CSSProperties => ({ transform: `translate(${px(x)}, ${px(y)})` });
return (
<div
ref={rootRef}
className={["iiw", className].filter(Boolean).join(" ")}
data-in={ready ? "" : undefined}
style={{ ...(vars as CSSProperties), ...style }}
{...rest}
>
<style>{CSS}</style>
<div className="iiw-layer" aria-hidden="true">
<div className="iiw-plane">
<div className="iiw-track" ref={trackRef}>
{cells.map((cell) => (
<div key={`s${cell.c},${cell.r}`} className="iiw-at" style={at(cell.x, cell.y)}>
<div className="iiw-sh iiw-in-sh" style={{ "--iiw-d": `${Math.round(cell.d * ENTER_SPREAD_MS)}ms` } as CSSProperties} />
</div>
))}
{cells.map((cell) => (
<div key={`c${cell.c},${cell.r}`} style={at(cell.x, cell.y)} className="iiw-at">
<div className="iiw-card" data-key={`${cell.c},${cell.r}`}>
<div className="iiw-face iiw-in" style={{ "--iiw-d": `${Math.round(cell.d * ENTER_SPREAD_MS)}ms` } as CSSProperties}>
{near ? <img src={picOf(cell.c, cell.r)} alt="" draggable={false} decoding="async" /> : null}
</div>
</div>
</div>
))}
</div>
</div>
</div>
{children}
</div>
);
}
export default IsometricWall;
```
Usage
Wrap a section's content in it, pass your pictures and give it a size. Everything inside sits above the wall.
"use client";
import { IsometricWall } from "@/components/ui/isometric-wall";
// 16 pictures look best. Any size: each one is cropped to a 3:2 card.
const PHOTOS = ["/wall/01.webp", "/wall/02.webp", "/wall/03.webp" /* … */];
export function Hero() {
return (
<IsometricWall
images={PHOTOS}
className="flex min-h-[640px] flex-col items-center justify-center gap-6 px-6 text-center"
>
<h1 className="text-5xl font-semibold tracking-tight">Components that move</h1>
<a href="/docs" className="rounded-full bg-foreground px-5 py-2.5 text-background">
Browse components
</a>
</IsometricWall>
);
}For a whole page, leave it empty and fix it to the screen, so it stays one screen big however long the page is.
// Behind a whole page: fixed to the screen, under everything.
<IsometricWall images={PHOTOS} className="fixed inset-0 -z-10" />How it moves
The cards lie on a floor tipped back 56° and turned 45°, like prints on a table seen from above. They stand in diagonal columns, every other column half a card further along, and every column slides along itself, up and to the left, at speed px a second, forever.
Hover a card and it rises lift px off the floor in 320ms, with a quick start and a long soft finish, while its shadow slides further out, grows wider and turns softer. Move away and it lands again in 480ms, a touch slower than it rose, so a fast sweep across the wall leaves a gentle wave behind the mouse. The drift never stops for a hovered card: it lifts and keeps moving, and when it drifts out from under a still mouse the next card takes over. When it first comes into view the cards fade in and settle onto the floor, from the middle outward. Phones get the drift without the lift. With reduced motion the wall stays still, the cards only fade in, and a hovered card only deepens its shadow. Off screen it pauses, and pictures load only when it comes near.
Props
| Prop | Default | What it does |
|---|---|---|
images | — | The pictures, as URLs. Any size: each is cropped to a 3:2 card. 16 look best; with fewer, the same picture comes back more often. Use small WebP files (about 480px wide). |
columns | 7, 5 or 3 | About how many columns across the box. By default 7 on a wide box, 5 from 640px to 1024px and 3 below 640px, so the cards keep a good size on every screen. |
speed | 12 | How fast the columns slide along their diagonal, in px a second. 0 holds it still. |
lift | 8 | How far a hovered card rises off the floor, in px on screen. |
opacity | 0.45 | How strong the pictures are in light mode, from 0 to 1. Lower is calmer. |
darkOpacity | 0.18 | How strong the pictures are in dark mode, from 0 to 1. Kept low so bright photos never glare on a dark page. |
radius | 14 | Card corners, in px. |
children | — | Your content. It sits above the wall and works as normal: text can be selected and buttons clicked. |
className / style | — | On the box. Give it a size (or let it fill its parent). The floor is your page color, so the wall has no background of its own. |