Story Cards
Customer stories that open up one at a time: a row of photo slivers with one story open in the middle. The open story folds away as the next grows into place, every card on its own springs, its words resolving out of a blur and its headline number counting up.
“We care about every first impression, and now booking with us is the easy part.”

“Notes write themselves, so the team spends that time with clients instead.”

“I use it every single day. Honestly, I couldn't run the business without it.”

“Reminders cut no-shows to zero and changed the tone of every consult.”

“Prospects book themselves the moment they're interested. No waiting on us.”

“New hires find a time with the right person on day one, without asking.”

“It scaled with us from five people to five hundred without a hitch.”

Tweak
LIVELIVEText
Motion
Usage
Follows your tweaks.
import { StoryCards } from "@/components/inreact/story-cards";
const stories = [
{ stat: "80%", label: "fewer scheduling emails", quote: "…", name: "Dana Whitfield", role: "Studio owner", photo: "/customers/dana.jpg" },
// ...
];
export function Stories() {
return (
<section className="h-[600px]">
<StoryCards stories={stories} />
</section>
);
}Install with the CLI
npx shadcn@latest add https://inreact.vercel.app/r/story-cards.jsonOr copy the source
Install the dependencies, then save this as components/inreact/story-cards.tsx.
npm install gsap"use client";
import { gsap } from "gsap";
import { useEffect, useRef, useState } from "react";
/**
* Story Cards: customer stories that open up one at a time.
*
* A row of photo slivers with one story open in the middle: a big result, the
* customer's words and their photo. Every few seconds (or when you click a
* sliver, drag, use the arrow keys) the open story folds back into a sliver
* while the next one grows into place. Every card rides its own springs, so
* the row reflows like one piece: the opening card squashes as it widens and
* overshoots a touch, its words resolve out of a blur, and its headline number
* counts up. A thin bar shows when the next story comes; hovering pauses it.
*
* <StoryCards stories={[{ stat: "80%", label: "fewer scheduling emails", quote: "...", name: "...", photo: "..." }]} />
*/
export interface Story {
/** The headline result, e.g. "80%" or "$1,200" or "3 to 5 hours". Its number counts up. */
stat: string;
/** What the result is, e.g. "fewer scheduling emails". */
label: string;
quote: string;
name: string;
role?: string;
photo: string;
focus?: string;
}
export interface StoryCardsProps {
stories: Story[];
eyebrow?: string;
title?: string;
/** Seconds per story; 0 turns autoplay off. */
interval?: number;
/** Section background (CSS). */
background?: string;
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
const DW = 980, DH = 560;
const OPEN = { w: 520, h: 300, text: 236 };
const SLIV = [
{ w: 64, h: 200 },
{ w: 46, h: 150 },
{ w: 34, h: 112 },
];
const GAP = 14, PAD = 6;
/** "80%" → { pre: "", num: 80, dec: 0, post: "%" }; "$1,200" → { pre: "$", num: 1200, comma: true } */
function parseStat(s: string) {
const m = s.match(/^(\D*?)([\d,]*\.?\d+)(.*)$/);
if (!m) return null;
const raw = m[2];
return { pre: m[1], num: parseFloat(raw.replace(/,/g, "")), dec: raw.includes(".") ? raw.split(".")[1].length : 0, comma: raw.includes(","), post: m[3] };
}
function fmt(p: NonNullable<ReturnType<typeof parseStat>>, v: number) {
let t = v.toFixed(p.dec);
if (p.comma) t = Number(t).toLocaleString("en-US", { minimumFractionDigits: p.dec, maximumFractionDigits: p.dec });
return `${p.pre}${t}${p.post}`;
}
export function StoryCards({
stories,
eyebrow = "Customer stories",
title = "Real people. Real results.",
interval = 4.5,
background = "linear-gradient(180deg, #3f63d6 0%, #6f6fe0 30%, #b58be6 58%, #f2c6d9 82%, #f8e6dc 100%)",
className,
}: StoryCardsProps) {
const wrapRef = useRef<HTMLDivElement>(null);
const stageRef = useRef<HTMLDivElement>(null);
const cards = useRef<(HTMLDivElement | null)[]>([]);
const texts = useRef<(HTMLDivElement | null)[]>([]);
const stats = useRef<(HTMLSpanElement | null)[]>([]);
const barRef = useRef<HTMLDivElement>(null);
const [scale, setScale] = useState(1);
const [active, setActive] = useState(0);
const activeRef = useRef(0);
const n = stories.length;
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();
}, []);
/* ---------- the row: every card on springs, the layout derived from them each frame ---------- */
const go = useRef<(k: number) => void>(() => {});
useEffect(() => {
const stage = stageRef.current;
if (!stage || !n) return;
const still = reduced();
const S = stories.map((_, k) => {
let d0 = ((k % n) + n) % n;
if (d0 > n / 2) d0 -= n;
const open = d0 === 0;
const sl = SLIV[Math.min(2, Math.abs(d0) - 1)] ?? SLIV[2];
return { w: open ? OPEN.w : sl.w, h: open ? OPEN.h : sl.h, vw: 0, vh: 0, t: open ? OPEN.text : 0, vt: 0, op: 1, s: 0, vs: 0 };
});
const last = stories.map(() => "");
const rel = (k: number) => {
let d = (((k - activeRef.current) % n) + n) % n;
if (d > n / 2) d -= n;
return d;
};
const tick = (_t: number, ms: number) => {
const dt = Math.min(ms / 1000, 1 / 30);
const h = dt / 2;
for (let k = 0; k < n; k++) {
const c = S[k];
const d = rel(k), a = Math.abs(d);
const tw = a === 0 ? OPEN.w : (SLIV[a - 1] ?? SLIV[2]).w;
const th = a === 0 ? OPEN.h : (SLIV[a - 1] ?? SLIV[2]).h;
const tt = a === 0 ? OPEN.text : 0;
const top = a > 3 ? 0 : 1;
for (let i = 0; i < 2; i++) {
if (still) {
c.w = tw;
c.h = th;
c.t = tt;
break;
}
// a little overshoot when growing; firmer when folding away
const grow = tw > c.w;
const k1 = grow ? 150 : 210, z1 = grow ? 0.6 : 0.78, c1 = 2 * z1 * Math.sqrt(k1);
c.vw += (k1 * (tw - c.w) - c1 * c.vw) * h;
c.w += c.vw * h;
c.vh += (k1 * (th - c.h) - c1 * c.vh) * h;
c.h += c.vh * h;
const k2 = tt > c.t ? 120 : 260, c2 = 2 * (tt > c.t ? 0.66 : 0.85) * Math.sqrt(k2);
c.vt += (k2 * (tt - c.t) - c2 * c.vt) * h;
c.t += c.vt * h;
// squash as it widens fast, stretch as it narrows
const ks = 340, cs = 2 * 0.3 * Math.sqrt(ks);
c.vs += (ks * (clamp(-0.08, 0.08, c.vw * 0.00022) - c.s) - cs * c.vs) * h;
c.s += c.vs * h;
}
c.op += (top - c.op) * Math.min(1, dt * 10);
}
// lay the row out from the current widths, centred on the open card
const order = stories.map((_, k) => k).sort((x, y) => rel(x) - rel(y));
const ci = order.findIndex((k) => rel(k) === 0);
const xs: number[] = [];
let x = DW / 2 - S[order[ci]].w / 2;
xs[order[ci]] = x;
for (let i = ci + 1, xr = x + S[order[ci]].w + GAP; i < order.length; i++) {
xs[order[i]] = xr;
xr += S[order[i]].w + GAP;
}
for (let i = ci - 1, xl = x - GAP; i >= 0; i--) {
xl -= S[order[i]].w;
xs[order[i]] = xl;
xl -= GAP;
}
const baseY = 182 + OPEN.h / 2;
for (let k = 0; k < n; k++) {
const c = S[k];
const s = c.s;
const tr = `translate3d(${xs[k].toFixed(2)}px,${(baseY - c.h / 2).toFixed(2)}px,0) scale(${(1 + s * 0.3).toFixed(4)},${(1 - s).toFixed(4)})`;
const key = `${tr}|${c.w.toFixed(1)}|${c.h.toFixed(1)}|${c.t.toFixed(1)}|${c.op.toFixed(2)}`;
if (key !== last[k]) {
const el = cards.current[k], tx = texts.current[k];
if (el) {
el.style.transform = tr;
el.style.width = `${c.w.toFixed(2)}px`;
el.style.height = `${c.h.toFixed(2)}px`;
el.style.opacity = c.op.toFixed(2);
}
if (tx) tx.style.width = `${Math.max(0, c.t).toFixed(2)}px`;
last[k] = key;
}
}
};
gsap.ticker.add(tick);
// the open story's words resolve out of a blur, and its number counts up
const reveal = (k: number) => {
const tx = texts.current[k];
if (!tx) return;
const lines = Array.from(tx.querySelectorAll<HTMLElement>("[data-line]"));
gsap.killTweensOf(lines);
if (!still) gsap.fromTo(lines, { opacity: 0, y: 8, filter: "blur(6px)" }, { opacity: 1, y: 0, filter: "blur(0px)", duration: 0.7, stagger: 0.08, ease: "power3.out", delay: 0.22, clearProps: "filter" });
const p = parseStat(stories[k].stat), el = stats.current[k];
if (p && el) {
const o = { v: 0 };
gsap.killTweensOf(o);
if (still) el.textContent = stories[k].stat;
else
gsap.to(o, {
v: p.num,
duration: 1.2,
delay: 0.25,
ease: "power3.out",
onUpdate: () => void (el.textContent = fmt(p, o.v)),
onComplete: () => void (el.textContent = stories[k].stat),
});
}
};
reveal(0);
// autoplay with a progress bar; hover pauses
let paused = false, took = false;
const bar = barRef.current;
let barTween: gsap.core.Tween | null = null;
const startBar = () => {
barTween?.kill();
if (!bar || !interval || still) return;
gsap.set(bar, { scaleX: 0 });
barTween = gsap.to(bar, { scaleX: 1, duration: interval, ease: "none", onComplete: () => !took && go.current(activeRef.current + 1) });
if (paused) barTween.pause();
};
go.current = (k: number) => {
const i = ((k % n) + n) % n;
if (i === activeRef.current) return;
const prev = activeRef.current;
activeRef.current = i;
setActive(i);
// the folding card's words fade first
const pt = texts.current[prev]?.querySelectorAll<HTMLElement>("[data-line]");
if (pt && !still) gsap.to(pt, { opacity: 0, filter: "blur(4px)", duration: 0.2, ease: "power2.in", overwrite: true });
reveal(i);
startBar();
};
startBar();
const onEnter = (e: PointerEvent) => {
if (!e.isTrusted) return;
paused = true;
barTween?.pause();
};
const onLeave = () => {
paused = false;
barTween?.resume();
};
// click a sliver; drag / swipe
let sx = 0, down = false;
const onDown = (e: PointerEvent) => {
down = true;
sx = e.clientX;
};
const onUp = (e: PointerEvent) => {
if (!down) return;
down = false;
const dx = e.clientX - sx;
if (Math.abs(dx) > 30) {
if (e.isTrusted) took = true;
go.current(activeRef.current + (dx < 0 ? 1 : -1));
return;
}
const card = (e.target as HTMLElement).closest<HTMLElement>("[data-story]");
if (card) {
const k = Number(card.dataset.story);
if (k !== activeRef.current) go.current(k);
}
};
const onKey = (e: KeyboardEvent) => {
if (e.key !== "ArrowRight" && e.key !== "ArrowLeft") return;
e.preventDefault();
go.current(activeRef.current + (e.key === "ArrowRight" ? 1 : -1));
};
stage.addEventListener("pointerenter", onEnter);
stage.addEventListener("pointerleave", onLeave);
stage.addEventListener("pointerdown", onDown);
stage.addEventListener("pointerup", onUp);
stage.addEventListener("keydown", onKey);
return () => {
gsap.ticker.remove(tick);
barTween?.kill();
stage.removeEventListener("pointerenter", onEnter);
stage.removeEventListener("pointerleave", onLeave);
stage.removeEventListener("pointerdown", onDown);
stage.removeEventListener("pointerup", onUp);
stage.removeEventListener("keydown", onKey);
};
}, [n, stories, interval]);
return (
<div ref={wrapRef} className={["relative h-full w-full overflow-hidden", className].filter(Boolean).join(" ")} style={{ background }}>
<div
ref={stageRef}
tabIndex={0}
role="region"
aria-roledescription="carousel"
aria-label={title}
className="absolute top-1/2 left-1/2 touch-pan-y outline-none select-none"
style={{ width: DW, height: DH, marginLeft: -DW / 2, marginTop: -DH / 2, transform: `scale(${scale})` }}
>
<div className="absolute inset-x-0 top-[40px] text-center text-white">
<div className="font-mono text-[11px] tracking-[0.18em] text-white/80 uppercase">{eyebrow}</div>
<div className="mx-auto mt-3 max-w-[560px] text-[44px] leading-[1.08] font-medium tracking-[-0.025em]">{title}</div>
</div>
{stories.map((s, k) => (
<div
key={k}
ref={(el) => void (cards.current[k] = el)}
data-story={k}
role="group"
aria-roledescription="slide"
aria-label={`${s.name}: ${s.stat} ${s.label}`}
className={`absolute top-0 left-0 flex overflow-hidden rounded-[20px] bg-white will-change-transform ${k === active ? "" : "cursor-pointer"}`}
style={{ padding: PAD, gap: 0, boxShadow: "0 2px 6px rgba(30,20,60,.08), 0 18px 40px rgba(30,20,60,.18)" }}
>
{/* the story */}
<div ref={(el) => void (texts.current[k] = el)} className="h-full shrink-0 overflow-hidden" style={{ width: k === 0 ? OPEN.text : 0 }}>
<div className="flex h-full flex-col text-[#16161c]" style={{ width: OPEN.text, padding: "14px 18px 14px 12px" }}>
<div data-line className="text-[25px] leading-[1.1] font-semibold tracking-[-0.02em]">
<span ref={(el) => void (stats.current[k] = el)}>{s.stat}</span> {s.label}
</div>
<p data-line className="mt-auto font-serif text-[15.5px] leading-[1.38] text-[#16161c]/90">“{s.quote}”</p>
<div data-line className="mt-4 text-[12px]">
<span className="font-semibold">{s.name}</span>
{s.role && <span className="text-[#16161c]/55"> · {s.role}</span>}
</div>
</div>
</div>
{/* the photo */}
<div className="relative h-full min-w-0 flex-1 overflow-hidden rounded-[15px] bg-[#ddd]">
<img src={s.photo} alt="" draggable={false} className="pointer-events-none absolute inset-0 h-full w-full object-cover" style={{ objectPosition: s.focus ?? "50% 30%" }} />
</div>
</div>
))}
{/* dots and the time until the next story */}
<div className="absolute inset-x-0 top-[506px] flex items-center justify-center gap-2">
{stories.map((_, k) => (
<button
key={k}
type="button"
aria-label={`Story ${k + 1}`}
aria-current={k === active}
onClick={() => go.current(k)}
className={`h-[6px] rounded-full transition-[width,background-color] duration-500 ${k === active ? "w-[22px] bg-white" : "w-[6px] bg-white/50 hover:bg-white/80"}`}
/>
))}
</div>
{/* time until the next story */}
<div className="absolute top-[526px] left-1/2 h-[2px] w-[90px] -translate-x-1/2 overflow-hidden rounded-full bg-white/30">
<div ref={barRef} className="h-full w-full origin-left scale-x-0 rounded-full bg-white" />
</div>
</div>
</div>
);
}
export default StoryCards;
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 propsstories{ stat; label; quote; name; role?; photo; focus? }[]The stories (the stat's number counts up).eyebrowstringSmall label above the title.default "Customer stories"default "Customer stories"titlestringSection title.default "Real people. Real results."default "Real people. Real results."intervalnumberSeconds per story; 0 turns autoplay off.default 4.5default 4.5backgroundstringSection background (CSS).classNamestringExtra classes (give the section a height).