Components78 / 118
Supporter Stack
Your latest supporters as a 3D stack of portraits, the newest in front with a fresh green edge. Swipe and they flick through with inertia; the one that lands in front squashes as it lands before its name and donation settle in. Double-tap the front photo for a burst of hearts.
Social proofSocial proof3D stack3D stackSwipeSwipeHeartsHeartsSquash & stretchSquash & stretchGSAPGSAP
Latest donations
01/24








Marcus Hale
$100 donation•10m ago
Swipe or flick the photosDouble-click the front photo
Tweak
LIVELIVEText
Look
#b9f26a
Usage
Follows your tweaks.
usage.tsx
import { SupporterStack } from "@/components/inreact/supporter-stack";
const supporters = [
{ name: "Marcus Hale", photo: "/people/marcus.jpg", detail: "$100 donation", time: "10m ago" },
{ name: "Amy Stockwell", photo: "/people/amy.jpg", detail: "$200 donation", time: "11m ago" },
// ...
];
export function Donations() {
return (
<div className="h-[440px] w-full">
<SupporterStack items={supporters} />
</div>
);
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/supporter-stack.jsonOr copy the source
Install the dependencies, then save this as components/inreact/supporter-stack.tsx.
terminal
npm install gsapcomponents/inreact/supporter-stack.tsx
"use client";
import { gsap } from "gsap";
import { useEffect, useRef, useState } from "react";
/**
* Supporter Stack: the latest supporters as a stack of portraits.
*
* Photos stand in a 3D stack: the newest one in front with a fresh green edge,
* the rest receding and turning away on either side. Swipe (or drag, scroll
* sideways, use the arrow keys) and they flick through with inertia,
* stretching with speed; the one that lands in front squashes as it lands
* before its edge and caption settle in. Double-click (or double-tap) the
* front photo and a burst of hearts pops out of it, each one squashing in,
* wobbling up and fading. The whole stack leans a touch toward your cursor.
*
* <SupporterStack title="Latest donations" items={[{ name: "Ada", photo: "/ada.jpg", detail: "$50 donation", time: "2m ago" }]} />
*/
export interface Supporter {
name: string;
photo: string;
/** object-position for the photo. */
focus?: string;
/** e.g. "$100 donation" */
detail: string;
/** e.g. "10m ago" */
time?: string;
}
export interface SupporterStackProps {
items: Supporter[];
title?: string;
/** Total shown in the counter (defaults to the number of items). */
total?: number;
/** The front card's edge. */
accent?: string;
onChange?: (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));
// laid out once at this size and scaled to fit, so it looks the same at any size
const DW = 640, DH = 440, CW = 228, CH = 236;
const HEARTS = 16;
export function SupporterStack({ items, title = "Latest donations", total, accent = "#b9f26a", onChange, className }: SupporterStackProps) {
const wrapRef = useRef<HTMLDivElement>(null);
const stageRef = useRef<HTMLDivElement>(null);
const deckRef = useRef<HTMLDivElement>(null);
const cards = useRef<(HTMLDivElement | null)[]>([]);
const rings = useRef<(HTMLDivElement | null)[]>([]);
const hearts = useRef<(HTMLSpanElement | null)[]>([]);
const capRef = useRef<HTMLDivElement>(null);
const [scale, setScale] = useState(1);
const [shown, setShown] = useState(0);
const n = items.length;
const onChangeRef = useRef(onChange);
onChangeRef.current = onChange;
// scale the design to the space it's given
useEffect(() => {
const el = wrapRef.current;
if (!el) return;
const ro = new ResizeObserver(([e]) => setScale(Math.min(e.contentRect.width / DW, (e.contentRect.height || DH) / DH)));
ro.observe(el);
return () => ro.disconnect();
}, []);
useEffect(() => {
const stage = stageRef.current, deck = deckRef.current;
if (!stage || !deck || !n) return;
const still = reduced();
const st = { p: 0, v: 0, target: 0, drag: false, land: 0, vland: 0, lx: 0, ly: 0, tlx: 0, tly: 0, settled: 1 };
let current = 0;
const last = items.map(() => "");
let lastDeck = "";
const go = (to: number) => {
st.target = to;
const i = ((Math.round(to) % n) + n) % n;
if (i !== current) {
current = i;
setShown(i);
onChangeRef.current?.(i);
}
};
const tick = (_t: number, ms: number) => {
const dt = Math.min(ms / 1000, 1 / 30);
const h = dt / 2;
for (let s = 0; s < 2; s++) {
if (!st.drag) {
if (still) {
st.p = st.target;
st.v = 0;
} else {
const k = 90, c = 2 * 0.8 * Math.sqrt(k);
st.v += (k * (st.target - st.p) - c * st.v) * h;
st.p += st.v * h;
}
}
// the landing jelly
const kl = 300, cl = 2 * 0.22 * Math.sqrt(kl);
st.vland += (-kl * st.land - cl * st.vland) * h;
st.land += st.vland * h;
}
const speed = Math.abs(st.v);
// when it comes to rest, the front card lands with a squash and its edge appears
const settled = !st.drag && speed < 0.15 && Math.abs(st.target - st.p) < 0.05 ? 1 : 0;
if (settled && !st.settled && !still) st.vland -= 2.2;
st.settled += (settled - st.settled) * Math.min(1, dt * 8);
if (capRef.current) capRef.current.style.opacity = st.settled.toFixed(3);
st.lx += (st.tlx - st.lx) * Math.min(1, dt * 5);
st.ly += (st.tly - st.ly) * Math.min(1, dt * 5);
const dk = `rotateX(${st.ly.toFixed(2)}deg) rotateY(${st.lx.toFixed(2)}deg)`;
if (dk !== lastDeck) {
deck.style.transform = dk;
lastDeck = dk;
}
const stretch = still ? 0 : Math.min(0.1, speed * 0.025);
for (let k = 0; k < n; k++) {
let d = (((k - st.p) % n) + n) % n;
if (d > n / 2) d -= n;
const a = Math.abs(d), sg = Math.sign(d);
// the stack: in front, then tucked behind on each side, turning away
const x = sg * (Math.min(a, 1) * CW * 0.72 + Math.max(0, Math.min(a, 3) - 1) * CW * 0.25);
const z = -Math.min(a, 3.2) * 85;
const ry = -sg * (Math.min(a, 1) * 24 + Math.max(0, Math.min(a, 3) - 1) * 5);
const sc = (1 - Math.min(a, 3) * 0.05) * (a < 0.5 ? 1 + st.land * (1 - a * 2) * 0.6 : 1);
const sy = a < 0.5 ? 1 - st.land * (1 - a * 2) : 1;
const op = a > 3.4 ? 0 : a > 2.6 ? (3.4 - a) / 0.8 : 1;
const tr = `translate3d(${x.toFixed(2)}px,0,${z.toFixed(2)}px) rotateY(${ry.toFixed(2)}deg) scale(${(sc * (1 + stretch)).toFixed(4)},${((sc * sy) / (1 + stretch)).toFixed(4)})`;
const key = `${tr}|${op.toFixed(2)}`;
if (key !== last[k]) {
const el = cards.current[k];
if (el) {
el.style.transform = tr;
el.style.opacity = op.toFixed(2);
el.style.zIndex = String(100 - Math.round(a * 10));
}
last[k] = key;
}
const ring = rings.current[k];
if (ring) ring.style.opacity = (a < 0.5 ? st.settled * (1 - a * 2) : 0).toFixed(3);
}
};
gsap.ticker.add(tick);
// hearts: pop in with a squash, wobble up, fade
let slot = 0;
const burst = (x: number, y: number) => {
if (still) return;
st.vland -= 1.6;
for (let i = 0; i < 7; i++) {
const el = hearts.current[slot++ % HEARTS];
if (!el) continue;
gsap.killTweensOf(el);
const ang = -Math.PI / 2 + (Math.random() - 0.5) * 2.2;
const dist = 40 + Math.random() * 70;
const s = 0.6 + Math.random() * 0.7;
const tx = x + Math.cos(ang) * dist, ty = y + Math.sin(ang) * dist;
gsap.set(el, { x, y, scale: 0, opacity: 1, rotation: (Math.random() - 0.5) * 40 });
gsap.timeline({ delay: i * 0.035 })
.to(el, { x: tx, y: ty, scaleX: s * 1.25, scaleY: s * 0.75, duration: 0.18, ease: "power2.out" })
.to(el, { scaleX: s * 0.9, scaleY: s * 1.12, duration: 0.14, ease: "power1.inOut" })
.to(el, { scaleX: s, scaleY: s, duration: 0.4, ease: "elastic.out(1, 0.4)" })
.to(el, { y: ty - 60 - Math.random() * 40, x: tx + (Math.random() - 0.5) * 30, rotation: `+=${(Math.random() - 0.5) * 50}`, opacity: 0, duration: 1.1, ease: "power1.in" }, 0.35);
}
};
// drag / flick
const local = (e: { clientX: number; clientY: number }) => {
const r = stage.getBoundingClientRect();
return { x: (e.clientX - r.left) / (r.width / DW), y: (e.clientY - r.top) / (r.height / DH) };
};
let sx = 0, sp = 0, lx = 0, lt = 0, moved = 0, id = -1, lastTap = 0;
const PX = CW * 0.6;
const onDown = (e: PointerEvent) => {
if (e.button !== 0) return;
id = e.pointerId;
st.drag = true;
sx = lx = local(e).x;
sp = st.p;
lt = performance.now();
moved = 0;
};
const onMove = (e: PointerEvent) => {
const q = local(e);
st.tlx = clamp(-1, 1, (q.x - DW / 2) / (DW / 2)) * 6;
st.tly = -clamp(-1, 1, (q.y - DH / 2) / (DH / 2)) * 4;
if (e.pointerId !== id || !st.drag) return;
const dx = q.x - sx;
moved = Math.max(moved, Math.abs(dx));
if (moved > 4 && !stage.hasPointerCapture(e.pointerId)) {
try {
stage.setPointerCapture(e.pointerId);
} catch {
/* capture is a nicety */
}
}
const now = performance.now(), ddt = Math.max(1, now - lt) / 1000;
st.v = st.v * 0.6 + (-(q.x - lx) / PX / ddt) * 0.4;
lx = q.x;
lt = now;
st.p = sp - dx / PX;
};
const onUp = (e: PointerEvent) => {
if (e.pointerId !== id) return;
id = -1;
if (!st.drag) return;
st.drag = false;
if (moved < 5) {
const q = local(e);
const card = (e.target as HTMLElement).closest<HTMLElement>("[data-sup]");
const k = card ? Number(card.dataset.sup) : -1;
let d = (((k - st.p) % n) + n) % n;
if (d > n / 2) d -= n;
const now = performance.now();
if (k >= 0 && Math.abs(d) < 0.5) {
// touch / pen: a double-tap sends hearts (mice use the browser's own
// double-click below, which follows the system's double-click speed)
if (e.pointerType !== "mouse" || !e.isTrusted) {
if (now - lastTap < 450) {
burst(q.x, q.y);
lastTap = 0;
} else lastTap = now;
}
go(Math.round(st.p));
} else if (k >= 0) go(Math.round(st.p + d));
else go(Math.round(st.p));
return;
}
go(Math.round(st.p + clamp(-4, 4, st.v * 0.35)));
};
const onLeave = () => {
st.tlx = st.tly = 0;
};
let wacc = 0, wlock = 0;
const onWheel = (e: WheelEvent) => {
const dx = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.shiftKey ? e.deltaY : 0;
if (!dx) return;
e.preventDefault();
const now = performance.now();
if (now < wlock) return;
wacc += dx;
if (Math.abs(wacc) > 40) {
go(Math.round(st.target) + Math.sign(wacc));
wacc = 0;
wlock = now + 300;
}
};
const onKey = (e: KeyboardEvent) => {
if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
e.preventDefault();
go(Math.round(st.target) + (e.key === "ArrowRight" ? 1 : -1));
} else if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
burst(DW / 2, DH * 0.42);
}
};
stage.addEventListener("pointerdown", onDown);
stage.addEventListener("pointermove", onMove);
stage.addEventListener("pointerup", onUp);
stage.addEventListener("pointercancel", onUp);
stage.addEventListener("pointerleave", onLeave);
stage.addEventListener("wheel", onWheel, { passive: false });
stage.addEventListener("keydown", onKey);
// a mouse double-click on the front photo sends hearts
const onDbl = (e: MouseEvent) => {
const card = (e.target as HTMLElement).closest<HTMLElement>("[data-sup]");
if (!card) return;
let d = (((Number(card.dataset.sup) - st.p) % n) + n) % n;
if (d > n / 2) d -= n;
if (Math.abs(d) >= 0.5) return;
const q = local(e);
burst(q.x, q.y);
};
stage.addEventListener("dblclick", onDbl);
return () => {
gsap.ticker.remove(tick);
hearts.current.forEach((el) => el && gsap.killTweensOf(el));
stage.removeEventListener("pointerdown", onDown);
stage.removeEventListener("pointermove", onMove);
stage.removeEventListener("pointerup", onUp);
stage.removeEventListener("pointercancel", onUp);
stage.removeEventListener("pointerleave", onLeave);
stage.removeEventListener("wheel", onWheel);
stage.removeEventListener("keydown", onKey);
stage.removeEventListener("dblclick", onDbl);
};
}, [n, items]);
const cur = items[shown];
const count = (v: number) => String(v).padStart(2, "0");
return (
<div ref={wrapRef} className={["relative h-full w-full", className].filter(Boolean).join(" ")}>
<div
ref={stageRef}
tabIndex={0}
role="region"
aria-roledescription="carousel"
aria-label={title}
className="absolute top-1/2 left-1/2 cursor-grab touch-pan-y outline-none select-none active:cursor-grabbing"
style={{ width: DW, height: DH, marginLeft: -DW / 2, marginTop: -DH / 2, transform: `scale(${scale})` }}
>
<div className="absolute inset-x-[44px] top-[28px] flex items-baseline justify-between text-[#111]">
<div className="text-[26px] font-semibold tracking-[-0.02em]">{title}</div>
<div className="text-[22px] font-medium tabular-nums tracking-[-0.01em]">
{count(shown + 1)}/{count(total ?? n)}
</div>
</div>
{/* the stack */}
<div className="absolute inset-x-0 top-[78px] h-[262px] [perspective:1100px]">
<div ref={deckRef} className="absolute inset-0 [transform-style:preserve-3d] will-change-transform">
{items.map((it, k) => (
<div
key={k}
ref={(el) => void (cards.current[k] = el)}
data-sup={k}
role="group"
aria-roledescription="slide"
aria-label={`${it.name}, ${it.detail}`}
className="absolute top-[13px] left-1/2 will-change-transform"
style={{ width: CW, height: CH, marginLeft: -CW / 2 }}
>
<div className="relative h-full w-full overflow-hidden rounded-[16px] bg-[#e9e9ec]" style={{ boxShadow: "0 2px 4px rgba(20,20,30,.08), 0 14px 30px rgba(20,20,30,.16)" }}>
<img src={it.photo} alt="" draggable={false} className="pointer-events-none h-full w-full object-cover" style={{ objectPosition: it.focus ?? "50% 30%" }} />
</div>
{/* the fresh edge on the front card */}
<div
ref={(el) => void (rings.current[k] = el)}
aria-hidden="true"
className="pointer-events-none absolute -inset-[1px] rounded-[17px] opacity-0"
style={{ boxShadow: `inset 0 0 0 2.5px ${accent}, inset 0 0 0 3.5px rgba(255,255,255,.6)` }}
/>
</div>
))}
</div>
{/* hearts */}
<div aria-hidden="true" className="pointer-events-none absolute inset-0" style={{ transform: "translateY(-78px)" }}>
{Array.from({ length: HEARTS }, (_, i) => (
<span key={i} ref={(el) => void (hearts.current[i] = el)} className="absolute top-0 left-0 opacity-0 will-change-transform" style={{ width: 0, height: 0 }}>
<svg viewBox="0 0 24 24" width="34" height="34" style={{ position: "absolute", left: -17, top: -17 }}>
<path d="M12 21s-7.5-4.6-9.6-9.2C.9 8.4 3 4.5 6.7 4.5c2.2 0 3.6 1.2 4.3 2.4.7-1.2 2.1-2.4 4.3-2.4 3.7 0 5.8 3.9 4.3 7.3C19.5 16.4 12 21 12 21Z" fill="#ff2f55" />
<path d="M7.2 7.4c-1.4.2-2.3 1.4-2.2 2.8" stroke="#fff" strokeOpacity=".75" strokeWidth="1.4" strokeLinecap="round" fill="none" />
</svg>
</span>
))}
</div>
</div>
{/* the caption settles in once the stack comes to rest */}
<div ref={capRef} aria-live="polite" className="absolute inset-x-0 top-[356px] text-center">
<div className="text-[16px] font-semibold text-[#111]">{cur?.name}</div>
<div className="mt-1 text-[15px] text-[#111]/85">
{cur?.detail}
{cur?.time && (
<>
<span className="mx-2 text-[#111]/40">•</span>
<span className="text-[#111]/45">{cur.time}</span>
</>
)}
</div>
</div>
</div>
</div>
);
}
export default SupporterStack;
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
6 propsitems{ name: string; photo: string; focus?: string; detail: string; time?: string }[]The supporters.titlestringHeading.default "Latest donations"default "Latest donations"totalnumberTotal for the counter (defaults to the number of items).accentstringThe front card's edge.default "#b9f26a"default "#b9f26a"onChange(index: number) => voidCalled when the front card changes.classNamestringExtra classes (give the container a height).