Components86 / 118
Press Wall
An endless, drifting wall of rounded tiles seen through a soft surface. Where your cursor is, the wall gives way like a finger pressed into a cushion: tiles under it sink small while the ones around swell toward the edges. Press and release to send a ripple through the wall and open the tile.
GalleryGalleryWebGLWebGLLensLensDragDragSpringsSpringsSquash & stretchSquash & stretchthree.jsthree.jsGSAPGSAP
Move over the wallPress and release a tile
Tweak
LIVELIVELook
0.85
3.3
Motion
0.16 tiles/s
Usage
Follows your tweaks.
usage.tsx
import { PressWall } from "@/components/inreact/press-wall";
const work = [
{ src: "/work/01.jpg", title: "Still life", href: "/work/still-life" },
{ src: "/work/02.jpg", title: "Studio portraits" },
// ...
];
export function Work() {
return <PressWall items={work} height={640} />;
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/press-wall.jsonOr copy the source
Install the dependencies, then save this as components/inreact/press-wall.tsx.
terminal
npm install gsap threecomponents/inreact/press-wall.tsx
"use client";
import { gsap } from "gsap";
import * as THREE from "three";
import { useEffect, useRef, useState } from "react";
/**
* Press Wall: an endless wall of rounded tiles seen through a soft surface.
*
* The wall drifts by itself. Where your cursor is, the surface gives way like
* a finger pressed into a cushion: tiles under it sink small while the ones
* around swell and curve toward the edges; the dent follows your cursor on a
* spring. Press and the dent goes deeper (the tile under you sinks in);
* release and it springs back, sending a ripple out through the wall. Drag
* or flick to scroll; tiles squash and stretch with the motion. Click (or
* Enter) opens the tile. One WebGL pass (three) + GSAP's ticker.
*
* <PressWall items={[{ src: "/work/1.jpg", title: "Chair 04", href: "/work/chair" }, ...]} />
*/
export interface PressTile {
src: string;
title?: string;
href?: string;
}
export interface PressWallProps {
items: PressTile[];
height?: number;
/** How deep the surface gives (0 is flat). */
depth?: number;
/** Tiles across the short side, roughly. */
density?: number;
/** Vertical drift, tiles per second (negative drifts down). */
drift?: number;
background?: string;
onSelect?: (item: PressTile, index: number) => void;
className?: string;
}
const reduced = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const clamp = (a: number, b: number, v: number) => Math.max(a, Math.min(b, v));
const GAP = 0.13, RAD = 0.15, LR = 0.42; // grid units / lens radius (short side = 1)
const AT = 256; // atlas cell, px
const VERT = /* glsl */ `
varying vec2 vUv;
void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }`;
const FRAG = /* glsl */ `
precision highp float;
varying vec2 vUv;
uniform sampler2D uAtlas;
uniform vec2 uAtlasGrid;
uniform float uCount;
uniform vec2 uRes;
uniform vec2 uOff; // camera, grid units
uniform float uScale; // grid units per short side (flat)
uniform vec2 uFocus; // the dent, screen units
uniform float uDepth;
uniform vec3 uRip; // ripple: centre xy, radius
uniform float uRipA;
uniform vec2 uSq; // squash: per-axis tile growth (grid units)
uniform vec3 uSinkA; // tile id xy, amount
uniform vec3 uSinkB;
uniform vec3 uBg;
float pickOf(vec2 id) { return mod(id.x * 7.0 + id.y * 3.0 + mod(id.x * id.y, 5.0), uCount); }
void main() {
vec2 s = (vUv - 0.5) * uRes / min(uRes.x, uRes.y);
// the dent: monotonic radial remap, small in the middle, swelling outward
vec2 d = s - uFocus;
float r = length(d);
float qr = r * (1.0 + uDepth) / (1.0 + uDepth * r / ${LR.toFixed(2)});
// the ripple travels out from where you let go
vec2 rd = s - uRip.xy;
float rr = length(rd);
float w = (rr - uRip.z) / 0.11;
vec2 rip = rr > 1e-4 ? rd / rr * uRipA * sin(w * 2.6) * exp(-w * w) : vec2(0.0);
vec2 g = (uFocus + (r > 1e-5 ? d / r * qr : vec2(0.0)) + rip) * uScale + uOff;
vec2 id = floor(g);
vec2 lc = fract(g) - 0.5; // -0.5..0.5 in the cell
// sinking tiles shrink inside their cell (two slots, so one can rise while another sinks)
float sink = uSinkA.z * step(abs(id.x - uSinkA.x) + abs(id.y - uSinkA.y), 0.5)
+ uSinkB.z * step(abs(id.x - uSinkB.x) + abs(id.y - uSinkB.y), 0.5);
vec2 hs = vec2(0.5 - ${GAP.toFixed(2)} * 0.5) + uSq;
hs *= 1.0 - 0.07 * sink;
float rad = ${RAD.toFixed(2)} * (1.0 + 0.5 * sink);
vec2 q = abs(lc) - (hs - rad);
float sd = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - rad;
float px = max(fwidth(g.x), fwidth(g.y)) * 0.9;
float a = 1.0 - smoothstep(-px, px, sd);
// soft contact shadow, a few hundredths of a tile
float sh = (1.0 - smoothstep(0.0, 0.06, sd)) * 0.07 * (1.0 - a);
float pick = pickOf(id);
vec2 at = vec2(mod(pick, uAtlasGrid.x), floor(pick / uAtlasGrid.x));
vec2 inner = clamp(lc / (hs * 2.0) * (1.0 - 0.05 * sink) + 0.5, 0.0, 1.0);
vec2 uv = (at + vec2(inner.x, 1.0 - inner.y)) / uAtlasGrid;
uv.y = 1.0 - uv.y;
vec3 col = texture2D(uAtlas, uv).rgb * (1.0 - 0.06 * sink);
vec3 bg = uBg * (1.0 - sh);
gl_FragColor = vec4(mix(bg, col, a), 1.0);
}`;
type Spring = { x: number; v: number; t: number };
const step = (b: Spring, k: number, c: number, h: number) => {
for (let i = 0; i < 2; i++) b.v += (k * (b.t - b.x) - c * b.v) * (h / 2), (b.x += b.v * (h / 2));
};
export function PressWall({ items, height = 560, depth = 0.85, density = 3.3, drift = 0.16, background = "#ececee", onSelect, className }: PressWallProps) {
const rootRef = useRef<HTMLDivElement>(null);
const hostRef = useRef<HTMLDivElement>(null);
const capRef = useRef<HTMLDivElement>(null);
const [W, setW] = useState(0);
const [cap, setCap] = useState<{ text: string; key: number }>({ text: "", key: 0 });
const n = items.length;
const selRef = useRef(onSelect);
selRef.current = onSelect;
useEffect(() => {
const el = rootRef.current;
if (!el) return;
const ro = new ResizeObserver(([e]) => setW(Math.round(e.contentRect.width)));
ro.observe(el);
return () => ro.disconnect();
}, []);
useEffect(() => {
const host = hostRef.current, root = rootRef.current, capEl = capRef.current;
if (!host || !root || !capEl || !W || !n) return;
const still = reduced();
const H = height, MIN = Math.min(W, H);
// every tile in one atlas (cover-cropped squares)
const cols = Math.min(8, Math.ceil(Math.sqrt(n))), rows = Math.ceil(n / cols);
const atlas = document.createElement("canvas");
atlas.width = cols * AT;
atlas.height = rows * AT;
const actx = atlas.getContext("2d")!;
actx.fillStyle = "#d9d9dc";
actx.fillRect(0, 0, atlas.width, atlas.height);
const tex = new THREE.CanvasTexture(atlas);
tex.colorSpace = THREE.SRGBColorSpace;
tex.minFilter = THREE.LinearMipmapLinearFilter;
tex.anisotropy = 4;
items.forEach((p, i) => {
const im = new Image();
im.crossOrigin = "anonymous";
im.onload = () => {
const x = (i % cols) * AT, y = Math.floor(i / cols) * AT;
const z = Math.max(AT / im.naturalWidth, AT / im.naturalHeight);
const w = im.naturalWidth * z, h = im.naturalHeight * z;
actx.save();
actx.beginPath();
actx.rect(x, y, AT, AT);
actx.clip();
actx.drawImage(im, x + (AT - w) / 2, y + (AT - h) / 2, w, h);
actx.restore();
tex.needsUpdate = true;
};
im.src = p.src;
});
const canvas = document.createElement("canvas");
canvas.style.cssText = "position:absolute;inset:0;width:100%;height:100%;";
host.appendChild(canvas);
let renderer: THREE.WebGLRenderer;
try {
renderer = new THREE.WebGLRenderer({ canvas, antialias: false });
} catch {
canvas.remove();
return;
}
renderer.setPixelRatio(Math.min(2, window.devicePixelRatio || 1));
renderer.setSize(W, H, false);
const bg = new THREE.Color(background);
const mat = new THREE.ShaderMaterial({
vertexShader: VERT,
fragmentShader: FRAG,
depthTest: false,
uniforms: {
uAtlas: { value: tex },
uAtlasGrid: { value: new THREE.Vector2(cols, rows) },
uCount: { value: n },
uRes: { value: new THREE.Vector2(W, H) },
uOff: { value: new THREE.Vector2(0.5, 0.5) },
uScale: { value: density },
uFocus: { value: new THREE.Vector2(0, 0) },
uDepth: { value: depth },
uRip: { value: new THREE.Vector3(0, 0, -9) },
uRipA: { value: 0 },
uSq: { value: new THREE.Vector2(0, 0) },
uSinkA: { value: new THREE.Vector3(1e4, 1e4, 0) },
uSinkB: { value: new THREE.Vector3(1e4, 1e4, 0) },
uBg: { value: new THREE.Vector3(bg.r, bg.g, bg.b) },
},
});
const scene = new THREE.Scene();
const quad = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), mat);
scene.add(quad);
const camera = new THREE.Camera();
const u = mat.uniforms;
// state: camera glide, the dent (springs), squash, two sink slots
const cam = { x: 0.5, y: 0.5, vx: 0, vy: 0, lx: 0.5, ly: 0.5, drag: false };
const fx: Spring = { x: 0, v: 0, t: 0 }, fy: Spring = { x: 0, v: 0, t: 0 };
const dep: Spring = { x: depth, v: 0, t: depth };
const sq: Spring = { x: 0, v: 0, t: 0 };
const dir = { x: 0, y: 1 };
const sinkA = { id: [1e4, 1e4], s: { x: 0, v: 0, t: 0 } as Spring };
const sinkB = { id: [1e4, 1e4], s: { x: 0, v: 0, t: 0 } as Spring };
const rip = { x: 0, y: 0, r: -9, a: 0 };
let pressed = false, inside = false;
let hover: [number, number] | null = null;
// screen (centred, short side 1, y up) → grid; mirrors the shader (without ripple)
const toGrid = (sx: number, sy: number) => {
const dx = sx - fx.x, dy = sy - fy.x, r = Math.hypot(dx, dy);
const k = r > 1e-5 ? (1 + dep.x) / (1 + (dep.x * r) / LR) : 1 + dep.x;
return { x: (fx.x + dx * k) * density + cam.x, y: (fy.x + dy * k) * density + cam.y };
};
const local = (cx: number, cy: number) => {
const b = root.getBoundingClientRect();
return { x: (cx - b.left - W / 2) / MIN, y: -(cy - b.top - H / 2) / MIN };
};
const fmod = (a: number, b: number) => a - b * Math.floor(a / b);
const pickOf = (ix: number, iy: number) => fmod(ix * 7 + iy * 3 + fmod(ix * iy, 5), n);
let capKey = 0;
const setHover = (t: [number, number] | null) => {
if (t && hover && t[0] === hover[0] && t[1] === hover[1]) return;
// the old tile rises from wherever it was (slot B), the new one sinks (slot A)
if (hover) {
sinkB.id = sinkA.id;
sinkB.s = { ...sinkA.s, t: 0 };
}
hover = t;
if (t) {
sinkA.id = t;
sinkA.s = { x: 0, v: 0, t: pressed ? 2.2 : 1 };
const it = items[pickOf(t[0], t[1])];
capKey += 1;
setCap({ text: it?.title ?? "", key: capKey });
} else {
sinkA.id = [1e4, 1e4];
sinkA.s = { x: 0, v: 0, t: 0 };
setCap((c) => ({ text: "", key: c.key }));
}
};
const tick = (_t: number, ms: number) => {
const dt = Math.min(ms / 1000, 1 / 30);
if (!cam.drag) {
// glide with friction toward the drift
const f = Math.pow(still ? 0 : 0.08, dt);
cam.vx *= f;
cam.vy = -drift * (still ? 0 : 1) + (cam.vy + drift * (still ? 0 : 1)) * f;
cam.x += cam.vx * dt;
cam.y += cam.vy * dt;
}
const rvx = (cam.x - cam.lx) / Math.max(dt, 1e-3), rvy = (cam.y - cam.ly) / Math.max(dt, 1e-3);
cam.lx = cam.x;
cam.ly = cam.y;
const sp = Math.hypot(rvx, rvy);
if (sp > 0.05) {
const e = Math.min(1, dt * 10);
dir.x += (Math.abs(rvx) / sp - dir.x) * e;
dir.y += (Math.abs(rvy) / sp - dir.y) * e;
}
if (still) {
fx.x = fx.t, fy.x = fy.t, dep.x = dep.t, sq.x = 0;
sinkA.s.x = sinkA.s.t;
sinkB.s.x = 0;
} else {
sq.t = clamp(0, 1, (sp - 0.3) * 0.11);
step(fx, 90, 13, dt);
step(fy, 90, 13, dt);
step(dep, 180, 9, dt); // jelly: overshoots on release
step(sq, 160, 8, dt);
step(sinkA.s, 260, 14, dt);
step(sinkB.s, 260, 14, dt);
if (rip.r > -1) {
rip.r += dt * 1.25;
rip.a *= Math.pow(0.18, dt);
if (rip.a < 0.0005) rip.r = -9;
}
}
const g = clamp(-0.6, 1.2, sq.x) * GAP * 0.42;
u.uOff.value.set(cam.x, cam.y);
u.uFocus.value.set(fx.x, fy.x);
u.uDepth.value = Math.max(0, dep.x);
u.uSq.value.set(g * (dir.x - dir.y), g * (dir.y - dir.x));
u.uSinkA.value.set(sinkA.id[0], sinkA.id[1], sinkA.s.x);
u.uSinkB.value.set(sinkB.id[0], sinkB.id[1], sinkB.s.x);
u.uRip.value.set(rip.x, rip.y, rip.r);
u.uRipA.value = rip.a;
renderer.render(scene, camera);
// keep the hovered tile current while the wall drifts under a still cursor
if (inside && !cam.drag && lastPt) {
const gq = toGrid(lastPt.x, lastPt.y);
setHover([Math.floor(gq.x), Math.floor(gq.y)]);
}
};
gsap.ticker.add(tick);
// pointer: the dent follows; drag scrolls; press sinks; release ripples
let lastPt: { x: number; y: number } | null = null;
let sx = 0, sy = 0, ox = 0, oy = 0, moved = 0, pid = -1, lt = 0, lpx = 0, lpy = 0;
const onEnter = () => {
inside = true;
};
const onMove = (e: PointerEvent) => {
inside = true;
const p = local(e.clientX, e.clientY);
lastPt = p;
fx.t = clamp(-0.9, 0.9, p.x);
fy.t = clamp(-0.9, 0.9, p.y);
if (!cam.drag || e.pointerId !== pid) return;
const dx = e.clientX - sx, dy = e.clientY - sy;
moved = Math.max(moved, Math.hypot(dx, dy));
if (moved > 5) {
if (pressed) {
pressed = false;
dep.t = depth;
setHover(null);
}
try {
if (!root.hasPointerCapture(e.pointerId)) root.setPointerCapture(e.pointerId);
} catch {
/* capture is a nicety */
}
}
const per = density / (MIN * (1 + depth) * 0.75);
cam.x = ox - dx * per;
cam.y = oy + dy * per;
const now = performance.now(), ddt = Math.max(1, now - lt) / 1000;
cam.vx = cam.vx * 0.5 + ((-(e.clientX - lpx) * per) / ddt) * 0.5;
cam.vy = cam.vy * 0.5 + (((e.clientY - lpy) * per) / ddt) * 0.5;
lpx = e.clientX;
lpy = e.clientY;
lt = now;
};
const onDown = (e: PointerEvent) => {
if (e.button !== 0) return;
pid = e.pointerId;
cam.drag = true;
sx = lpx = e.clientX;
sy = lpy = e.clientY;
ox = cam.x;
oy = cam.y;
cam.vx = cam.vy = 0;
moved = 0;
lt = performance.now();
const p = local(e.clientX, e.clientY);
lastPt = p;
fx.t = p.x;
fy.t = p.y;
// press deeper (anticipation for the release)
pressed = true;
dep.t = depth + 0.55;
const gq = toGrid(p.x, p.y);
setHover([Math.floor(gq.x), Math.floor(gq.y)]);
sinkA.s.t = 2.2;
};
const onUp = (e: PointerEvent) => {
if (e.pointerId !== pid) return;
pid = -1;
if (!cam.drag) return;
cam.drag = false;
const wasPress = pressed && moved < 5;
pressed = false;
dep.t = depth;
if (sinkA.s.t > 1) sinkA.s.t = 1;
if (wasPress) {
// springs back past rest, and a ripple runs out from the dent
dep.v -= 9;
sinkA.s.v -= 14;
rip.x = fx.x;
rip.y = fy.x;
rip.r = 0.02;
rip.a = still ? 0 : 0.022;
if (hover) {
const i = pickOf(hover[0], hover[1]);
const it = items[i];
if (it) {
selRef.current?.(it, i);
if (it.href) window.setTimeout(() => (window.location.href = it.href!), still ? 0 : 260);
}
}
return;
}
const cap = 9;
cam.vx = clamp(-cap, cap, cam.vx);
cam.vy = clamp(-cap, cap, cam.vy);
};
const onLeave = () => {
inside = false;
lastPt = null;
fx.t = 0;
fy.t = 0;
setHover(null);
};
const onKey = (e: KeyboardEvent) => {
const mv = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] }[e.key];
if (mv) {
e.preventDefault();
gsap.to(cam, { x: cam.x + mv[0], y: cam.y + mv[1], duration: 0.5, ease: "power3.out" });
}
if (e.key === "Enter") {
const gq = toGrid(fx.x, fy.x);
const i = pickOf(Math.floor(gq.x), Math.floor(gq.y));
dep.v -= 9;
rip.x = fx.x;
rip.y = fy.x;
rip.r = 0.02;
rip.a = still ? 0 : 0.022;
const it = items[i];
if (it) {
selRef.current?.(it, i);
if (it.href) window.location.href = it.href;
}
}
};
root.addEventListener("pointerenter", onEnter);
root.addEventListener("pointerdown", onDown);
root.addEventListener("pointermove", onMove);
root.addEventListener("pointerup", onUp);
root.addEventListener("pointercancel", onUp);
root.addEventListener("pointerleave", onLeave);
root.addEventListener("keydown", onKey);
return () => {
gsap.ticker.remove(tick);
gsap.killTweensOf(cam);
root.removeEventListener("pointerenter", onEnter);
root.removeEventListener("pointerdown", onDown);
root.removeEventListener("pointermove", onMove);
root.removeEventListener("pointerup", onUp);
root.removeEventListener("pointercancel", onUp);
root.removeEventListener("pointerleave", onLeave);
root.removeEventListener("keydown", onKey);
tex.dispose();
mat.dispose();
quad.geometry.dispose();
renderer.dispose();
canvas.remove();
};
}, [W, height, n, items, depth, density, drift, background]);
// the caption rolls in from below with a little squash
useEffect(() => {
const el = capRef.current?.firstElementChild as HTMLElement | null;
if (!el || !cap.text || reduced()) return;
gsap.fromTo(
el,
{ yPercent: 70, opacity: 0, scaleX: 0.9, scaleY: 1.12 },
{ keyframes: [{ yPercent: -8, opacity: 1, scaleX: 1.04, scaleY: 0.96, duration: 0.2, ease: "power2.out" }, { yPercent: 0, scaleX: 1, scaleY: 1, duration: 0.35, ease: "elastic.out(1, 0.5)" }], overwrite: true },
);
}, [cap]);
const fs = Math.round(clamp(8, 14, Math.min(W || height, height) * 0.026));
return (
<div
ref={rootRef}
tabIndex={0}
role="region"
aria-label="Gallery wall"
className={["relative w-full cursor-grab touch-none overflow-hidden outline-none select-none active:cursor-grabbing", className].filter(Boolean).join(" ")}
style={{ height, background }}
>
<div ref={hostRef} aria-hidden="true" className="absolute inset-0" />
<div ref={capRef} aria-live="polite" className="pointer-events-none absolute inset-x-0 bottom-[6%] flex justify-center overflow-hidden pb-2">
<div
key={cap.key}
className="inline-flex items-center rounded-full bg-[#141416] font-medium text-white shadow-[0_2px_6px_rgba(0,0,0,.12),0_12px_28px_rgba(0,0,0,.18)] transition-opacity duration-200"
style={{ fontSize: fs, gap: fs * 0.55, padding: `${fs * 0.6}px ${fs * 1.15}px`, opacity: cap.text ? 1 : 0, transformOrigin: "50% 100%" }}
>
{cap.text || " "}
<svg viewBox="0 0 24 24" width={fs} height={fs} fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<path d="M5 12h13M13 6l6 6-6 6" />
</svg>
</div>
</div>
</div>
);
}
export default PressWall;
One prompt, any AI agent
Paste into Claude Code, Codex, Cursor or Windsurf. It carries your tweaks and the full source, so the agent installs it exactly.
Props
8 propsitems{ src: string; title?: string; href?: string }[]The tiles (images are cover-cropped square).heightnumberHeight, px.default 560default 560depthnumberHow deep the surface gives (0 is flat).default 0.85default 0.85densitynumberTiles across the short side, roughly.default 3.3default 3.3driftnumberVertical drift, tiles per second.default 0.16default 0.16backgroundstringWall colour.default "#ececee"default "#ececee"onSelect(item, index) => voidCalled when a tile is opened.classNamestringExtra classes.