Components77 / 118
Badge Line
Your team as ID badges hanging from a wire. Each badge is a real pendulum: brush past and they swing, bumping their neighbours; pull one and the string stretches and the wire dips. Hover for a tilt and shimmer, click to flip it to a holographic back with bio, projects, email and a QR code.
TeamTeamCardsCardsPhysicsPhysics3D flip3D flipDragDragGSAPGSAP
Brush across, or pull a badgeClick a badge to flip it
Tweak
LIVELIVEPeople
4
Usage
Follows your tweaks.
usage.tsx
import { BadgeLine } from "@/components/inreact/badge-line";
const team = [
{
name: "Ines Marlow",
role: "Creative Director",
photo: "/team/ines.jpg",
location: "Lisbon, PT",
bio: "Sets the tone and keeps every project honest to the brief.",
projects: ["Harbor rebrand", "Field guide"],
email: "ines@yourstudio.com",
},
// ...
];
export function Team() {
return <BadgeLine people={team} height={460} />;
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/badge-line.jsonOr copy the source
Install the dependencies, then save this as components/inreact/badge-line.tsx.
terminal
npm install gsapcomponents/inreact/badge-line.tsx
"use client";
import { gsap } from "gsap";
import { useEffect, useMemo, useRef, useState } from "react";
/**
* Badge Line: your team as ID badges hanging from a wire.
*
* Each badge hangs on its own string from a sagging wire, and it really
* hangs: it's a pendulum. Brush the cursor across them and they swing; badges
* that swing into each other bump apart. Point at one and it tilts toward you
* while a shimmer runs across it. Grab one and pull: the string stretches,
* the wire dips, and when you let go it bounces and swings back. Click (or
* tap) and it flips over, with a twist that overshoots and a kick that sets
* it swinging, to a holographic back with the person's bio, projects, email
* and a QR code.
*
* <BadgeLine people={[{ name: "Ines Marlow", role: "Creative Director", photo: "/team/ines.jpg", ... }]} />
*/
export interface BadgePerson {
name: string;
role: string;
photo: string;
/** object-position for the photo. */
focus?: string;
bio?: string;
location?: string;
projects?: string[];
email?: string;
href?: string;
}
export interface BadgeLineProps {
people: BadgePerson[];
/** Small label at the top of each badge. */
label?: string;
/** Height of the area, px. */
height?: number;
/** Badge width, px (defaults to fit). */
cardWidth?: number;
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 BW = 200, BH = 280; // badges are laid out at this size and scaled as a whole
/* a deterministic QR-style pattern (decorative) */
function Qr({ seed, s }: { seed: string; s: number }) {
const cells = useMemo(() => {
let h = 2166136261;
for (const ch of seed) h = Math.imul(h ^ ch.charCodeAt(0), 16777619);
const N = 21, out: [number, number][] = [];
const finder = (x: number, y: number) => (x < 7 && y < 7) || (x > 13 && y < 7) || (x < 7 && y > 13);
for (let y = 0; y < N; y++)
for (let x = 0; x < N; x++) {
if (finder(x, y)) continue;
h = Math.imul(h ^ (x * 31 + y), 2654435761);
if (((h >>> 13) & 3) === 0 || ((h >>> 7) & 1) === 1) out.push([x, y]);
}
return out;
}, [seed]);
const F = (x: number, y: number) => (
<g key={`${x}${y}`}>
<rect x={x} y={y} width={7} height={7} fill="#111" />
<rect x={x + 1} y={y + 1} width={5} height={5} fill="#fff" />
<rect x={x + 2} y={y + 2} width={3} height={3} fill="#111" />
</g>
);
return (
<svg viewBox="-1 -1 23 23" width={s} height={s} aria-hidden="true" shapeRendering="crispEdges" style={{ background: "#fff", borderRadius: 3 }}>
{cells.map(([x, y]) => (
<rect key={`${x}-${y}`} x={x} y={y} width={1} height={1} fill="#111" />
))}
{F(0, 0)}
{F(14, 0)}
{F(0, 14)}
</svg>
);
}
function Front({ p, i, label }: { p: BadgePerson; i: number; label: string }) {
return (
<div className="absolute inset-0 flex flex-col rounded-[18px] bg-white p-3 [backface-visibility:hidden]" style={{ boxShadow: "inset 0 0 0 1px rgba(0,0,0,.05), 0 2px 4px rgba(20,20,35,.06), 0 12px 26px rgba(20,20,35,.12)" }}>
<div className="flex items-center justify-between font-mono text-[7.5px] tracking-[0.12em] text-[#111]/45 uppercase">
<span>{label}</span>
<span>#{String(i + 1).padStart(2, "0")}</span>
</div>
<div className="relative mt-2 h-[132px] overflow-hidden rounded-[12px] bg-[#eee]">
<img src={p.photo} alt="" draggable={false} className="pointer-events-none h-full w-full object-cover" style={{ objectPosition: p.focus ?? "50% 25%" }} />
</div>
<div className="mt-3 text-[16px] leading-tight font-semibold tracking-[-0.01em] text-[#111]">{p.name}</div>
<div className="mt-0.5 text-[10.5px] text-[#111]/55">{p.role}</div>
<div className="mt-auto flex items-center justify-between border-t border-[#111]/8 pt-2.5">
<span className="font-mono text-[7.5px] tracking-[0.14em] text-[#111]/55 uppercase">View profile</span>
<span className="grid size-5 place-items-center rounded-full bg-[#111] text-white">
<svg viewBox="0 0 12 12" width="8" height="8" aria-hidden="true" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round">
<path d="M3 9 9 3M4.5 3H9v4.5" />
</svg>
</span>
</div>
</div>
);
}
function Back({ p, label }: { p: BadgePerson; label: string }) {
return (
<div
data-holo
className="absolute inset-0 flex flex-col overflow-hidden rounded-[18px] p-3 text-[#16161c] [backface-visibility:hidden] [transform:rotateY(180deg)]"
style={{
background: "linear-gradient(125deg, #f3e8ff 0%, #dff4ff 22%, #fff4d6 40%, #ffe1f4 58%, #d9fff1 76%, #e8e4ff 100%)",
backgroundSize: "220% 220%",
boxShadow: "inset 0 0 0 1px rgba(255,255,255,.6), 0 2px 4px rgba(20,20,35,.06), 0 12px 26px rgba(20,20,35,.12)",
}}
>
<div className="flex items-center justify-between font-mono text-[7.5px] tracking-[0.12em] text-[#16161c]/50 uppercase">
<span>{label} · ID</span>
<span className="size-3 rounded-full border border-[#16161c]/25" />
</div>
<div className="mt-2.5 flex items-center gap-2">
<img src={p.photo} alt="" draggable={false} className="pointer-events-none size-8 rounded-full object-cover" style={{ objectPosition: p.focus ?? "50% 25%" }} />
<div>
<div className="text-[12px] leading-tight font-semibold">{p.name}</div>
<div className="text-[8.5px] text-[#16161c]/60">{p.role}</div>
</div>
</div>
{p.location && <div className="mt-2 text-[8.5px] text-[#16161c]/60">◦ {p.location}</div>}
{p.bio && <p className="mt-2 text-[9.5px] leading-[1.35] text-[#16161c]/80">{p.bio}</p>}
{p.projects && p.projects.length > 0 && (
<>
<div className="mt-2.5 font-mono text-[7px] tracking-[0.14em] text-[#16161c]/45 uppercase">Selected projects</div>
<ul className="mt-1 space-y-0.5 text-[9px]">
{p.projects.slice(0, 3).map((x) => (
<li key={x} className="border-b border-[#16161c]/8 pb-0.5">
{x}
</li>
))}
</ul>
</>
)}
<div className="mt-auto flex items-end justify-between">
<div>
<div className="font-mono text-[7px] tracking-[0.14em] text-[#16161c]/45 uppercase">Let's connect</div>
{p.email && <div className="text-[8.5px]">{p.email}</div>}
</div>
<Qr seed={p.name} s={38} />
</div>
{/* the holographic sheen */}
<span data-sheen className="pointer-events-none absolute inset-[-40%] opacity-60 mix-blend-soft-light will-change-transform" style={{ background: "linear-gradient(115deg, transparent 38%, rgba(255,255,255,.95) 48%, transparent 58%)" }} />
</div>
);
}
export function BadgeLine({ people, label = "People · Studio", height = 460, cardWidth, className }: BadgeLineProps) {
const rootRef = useRef<HTMLDivElement>(null);
const ropeRef = useRef<SVGPathElement>(null);
const hangs = useRef<(HTMLDivElement | null)[]>([]);
const strings = useRef<(HTMLDivElement | null)[]>([]);
const cards = useRef<(HTMLDivElement | null)[]>([]);
const sheens = useRef<(HTMLSpanElement | null)[]>([]);
const [W, setW] = useState(0);
const n = people.length;
useEffect(() => {
const el = rootRef.current;
if (!el) return;
const ro = new ResizeObserver(([e]) => setW(e.contentRect.width));
ro.observe(el);
return () => ro.disconnect();
}, []);
// badges fill their share of the wire (with a little air), and fit the height
const CW = Math.round(cardWidth ?? clamp(36, 240, Math.min(((W * 0.88) / Math.max(1, n)) * 0.86, (height * 0.62 * BW) / BH)));
const K = CW / BW;
useEffect(() => {
const root = rootRef.current, rope = ropeRef.current;
if (!root || !rope || !W || !n) return;
const still = reduced();
const CH = BH * K;
const sag = Math.max(10, height * 0.045);
const longest = 0.2 * CH + 18 * K;
// the line sits centred in the height it's given
const x0 = W * 0.06, x1 = W * 0.94, ry = Math.max(14, (height - (sag + longest + CH)) * 0.42);
const ropeY = (x: number) => ry + sag * (1 - Math.pow(((x - x0) / (x1 - x0)) * 2 - 1, 2));
const span = x1 - x0;
// each badge: a pendulum on a string, a twist (flip) spring, a hover tilt, a string stretch
const B = people.map((_, i) => {
const ax = x0 + span * ((i + 0.5) / n);
const L = (i % 2 ? 0.2 : 0.1) * CH + 18 * K;
return {
ax, L,
th: 0, vth: 0, // swing, radians
yaw: 0, vyaw: 0, tyaw: 0, // twist / flip, degrees
tx: 0, ty: 0, ttx: 0, tty: 0, // hover tilt
st: 0, vst: 0, tst: 0, // string stretch, px
dip: 0, // the wire dips where it's pulled
hov: 0, thov: 0, sx: 0.5, sy: 0.5,
drag: false, flipped: false,
phase: i * 1.7,
};
});
const last = people.map(() => "");
let lastRope = "";
const tick = (time: number, ms: number) => {
const dt = Math.min(ms / 1000, 1 / 30);
const h = dt / 2;
for (let s = 0; s < 2; s++) {
B.forEach((b, i) => {
if (still) {
b.th = 0;
b.yaw = b.tyaw;
b.st = 0;
return;
}
if (!b.drag) {
// a pendulum: gravity over length, a little air, a breath of wind
const g = 9.8 * 120 / (b.L + CH * 0.5);
const wind = Math.sin(time * 0.9 + b.phase) * 0.06 + Math.sin(time * 2.3 + b.phase * 2) * 0.02;
b.vth += (-g * Math.sin(b.th) - 1.1 * b.vth + wind) * h;
b.th += b.vth * h;
}
const ky = 150, cy = 2 * 0.32 * Math.sqrt(ky);
b.vyaw += (ky * (b.tyaw - b.yaw) - cy * b.vyaw) * h;
b.yaw += b.vyaw * h;
const ks = 320, cs = 2 * 0.25 * Math.sqrt(ks);
b.vst += (ks * (b.tst - b.st) - cs * b.vst) * h;
b.st += b.vst * h;
b.hov += (b.thov - b.hov) * Math.min(1, h * 9);
b.tx += (b.ttx * b.hov - b.tx) * Math.min(1, h * 10);
b.ty += (b.tty * b.hov - b.ty) * Math.min(1, h * 10);
// neighbours that swing into each other bump apart
const nb = B[i + 1];
if (nb) {
const r1 = b.L + b.st + CH * 0.5, r2 = nb.L + nb.st + CH * 0.5;
const xa = b.ax + Math.sin(b.th) * r1, xb = nb.ax + Math.sin(nb.th) * r2;
const overlap = CW * 0.98 - (xb - xa);
if (overlap > 0) {
const push = overlap * 0.004;
b.vth -= push * 60 * h * 2;
nb.vth += push * 60 * h * 2;
}
}
});
}
// the wire, dipping a little where badges pull on it
const pts: string[] = [];
const S = 24;
for (let k = 0; k <= S; k++) {
const x = x0 + (span * k) / S;
let y = ropeY(x);
B.forEach((b) => {
const pull = Math.max(0, b.st) * 0.35 + Math.abs(b.th) * 3;
y += pull * Math.exp(-Math.pow((x - b.ax) / (span / n / 2.2), 2));
});
pts.push(`${x.toFixed(1)},${y.toFixed(1)}`);
}
const rp = `M${pts.join(" L")}`;
if (rp !== lastRope) {
rope.setAttribute("d", rp);
lastRope = rp;
}
B.forEach((b, i) => {
const pull = Math.max(0, b.st) * 0.35 + Math.abs(b.th) * 3;
const ay = ropeY(b.ax) + pull;
const len = b.L + b.st;
const hang = `translate3d(${b.ax.toFixed(2)}px,${ay.toFixed(2)}px,0) rotate(${((b.th * 180) / Math.PI).toFixed(3)}deg)`;
// squash and stretch with the string's bounce
const sq = clamp(-0.06, 0.06, b.vst * 0.0009);
const card = `translate(${(-BW / 2).toFixed(1)}px, ${len.toFixed(2)}px) scale(${(K * (1 - sq * 0.5)).toFixed(4)},${(K * (1 + sq)).toFixed(4)}) rotateY(${(b.yaw + b.ty).toFixed(2)}deg) rotateX(${b.tx.toFixed(2)}deg)`;
const key = `${hang}|${card}|${len.toFixed(1)}`;
if (key !== last[i]) {
const hg = hangs.current[i], str = strings.current[i], cd = cards.current[i];
if (hg) hg.style.transform = hang;
if (str) str.style.height = `${len.toFixed(2)}px`;
if (cd) cd.style.transform = card;
last[i] = key;
}
const sh = sheens.current[i];
if (sh) {
(sh.parentElement as HTMLElement).style.opacity = (b.hov * (b.flipped ? 0 : 1)).toFixed(3);
if (b.hov > 0.01) sh.style.transform = `translate3d(${((b.sx - 0.5) * 60).toFixed(1)}%,${((b.sy - 0.5) * 40).toFixed(1)}%,0)`;
}
// the holographic back shifts with the tilt
const holo = cards.current[i]?.querySelector<HTMLElement>("[data-holo]");
if (holo && b.flipped && b.hov > 0.01) holo.style.backgroundPosition = `${(50 + b.ty * 3).toFixed(1)}% ${(50 + b.tx * 3).toFixed(1)}%`;
});
};
gsap.ticker.add(tick);
// pointer: brush to swing, hover to tilt, drag to pull, click to flip
const idx = (e: Event) => {
const el = (e.target as HTMLElement).closest<HTMLElement>("[data-badge]");
return el ? Number(el.dataset.badge) : -1;
};
let lastX = 0, lastT = 0, over = -1;
let drag: { i: number; x: number; y: number; moved: number; vx: number; px: number; pt: number } | null = null;
const onMove = (e: PointerEvent) => {
const now = performance.now();
const vx = lastT ? (e.clientX - lastX) / Math.max(1, now - lastT) : 0;
lastX = e.clientX;
lastT = now;
const i = idx(e);
if (i !== over) {
if (over >= 0) B[over].thov = 0;
over = i;
// brushing past a badge nudges it swinging
if (i >= 0 && !still) B[i].vth += clamp(-1.2, 1.2, vx * 0.35);
}
if (i >= 0) {
const b = B[i];
b.thov = 1;
const r = cards.current[i]!.getBoundingClientRect();
b.sx = clamp(0, 1, (e.clientX - r.left) / r.width);
b.sy = clamp(0, 1, (e.clientY - r.top) / r.height);
b.tty = (b.sx - 0.5) * 18;
b.ttx = -(b.sy - 0.5) * 14;
}
if (drag) {
const b = B[drag.i];
const dx = e.clientX - drag.x, dy = e.clientY - drag.y;
drag.moved = Math.max(drag.moved, Math.hypot(dx, dy));
if (drag.moved > 5) {
b.drag = true;
const rr = b.L + CH * 0.5;
b.th = clamp(-1, 1, Math.atan2(dx, rr));
b.tst = clamp(-8, 60 * K + 10, dy * 0.6);
drag.vx = ((e.clientX - drag.px) / Math.max(1, now - drag.pt)) * 1000;
drag.px = e.clientX;
drag.pt = now;
}
}
};
const onDown = (e: PointerEvent) => {
const i = idx(e);
if (i < 0 || e.button !== 0) return;
drag = { i, x: e.clientX, y: e.clientY, moved: 0, vx: 0, px: e.clientX, pt: performance.now() };
try {
root.setPointerCapture(e.pointerId);
} catch {
/* capture is a nicety */
}
};
const onUp = () => {
if (!drag) return;
const b = B[drag.i];
if (drag.moved <= 5) {
// a click: flip it, with a twist that overshoots and a kick to the swing
b.flipped = !b.flipped;
b.tyaw = b.flipped ? 180 : 0;
if (!still) {
b.vth += (b.flipped ? 1 : -1) * 1.4;
b.vst += 90;
}
} else {
// a fling: the string snaps back and the badge swings off
b.drag = false;
b.tst = 0;
b.vth += clamp(-6, 6, (drag.vx / (b.L + CH * 0.5)) * 0.9);
}
drag = null;
};
const onLeave = () => {
if (over >= 0) B[over].thov = 0;
over = -1;
};
const onKey = (e: KeyboardEvent) => {
const i = idx(e);
if (i < 0 || (e.key !== "Enter" && e.key !== " ")) return;
e.preventDefault();
const b = B[i];
b.flipped = !b.flipped;
b.tyaw = b.flipped ? 180 : 0;
if (!still) b.vth += 1;
};
root.addEventListener("pointermove", onMove);
root.addEventListener("pointerdown", onDown);
root.addEventListener("pointerup", onUp);
root.addEventListener("pointercancel", onUp);
root.addEventListener("pointerleave", onLeave);
root.addEventListener("keydown", onKey);
return () => {
gsap.ticker.remove(tick);
root.removeEventListener("pointermove", onMove);
root.removeEventListener("pointerdown", onDown);
root.removeEventListener("pointerup", onUp);
root.removeEventListener("pointercancel", onUp);
root.removeEventListener("pointerleave", onLeave);
root.removeEventListener("keydown", onKey);
};
}, [W, height, n, K, CW, people]);
return (
<div ref={rootRef} className={["relative w-full touch-pan-y select-none", className].filter(Boolean).join(" ")} style={{ height }}>
{W > 0 && (
<>
<svg aria-hidden="true" className="pointer-events-none absolute inset-0 overflow-visible" width={W} height={height}>
<path ref={ropeRef} fill="none" stroke="#9a9aa2" strokeWidth={1.4} strokeLinecap="round" />
</svg>
{people.map((p, i) => (
<div key={i} ref={(el) => void (hangs.current[i] = el)} className="absolute top-0 left-0 will-change-transform" style={{ width: 0, height: 0 }}>
{/* the string and its clip */}
<div ref={(el) => void (strings.current[i] = el)} className="absolute top-0 left-[-0.6px] w-[1.2px] bg-[#9a9aa2]" />
<div className="absolute top-[-4px] left-[-4px] size-2 rounded-full bg-[#b9b9c0] shadow-[inset_0_1px_0_rgba(255,255,255,.7)]" />
<div className="absolute top-0 left-0 [perspective:900px]" style={{ perspectiveOrigin: `0px ${Math.round(BH * K * 0.6)}px` }}>
<div
ref={(el) => void (cards.current[i] = el)}
data-badge={i}
role="button"
tabIndex={0}
aria-label={`${p.name}, ${p.role}. Press to flip.`}
className="relative cursor-grab outline-none [transform-origin:50%_0%] [transform-style:preserve-3d] will-change-transform focus-visible:[&>div]:ring-2 focus-visible:[&>div]:ring-[#7a6cff]/50 active:cursor-grabbing"
style={{ width: BW, height: BH }}
>
{/* the clip at the top of the badge */}
<div className="absolute top-[-7px] left-1/2 z-10 h-[12px] w-[22px] -translate-x-1/2 rounded-[4px] bg-[#c9c9cf] shadow-[inset_0_1px_0_rgba(255,255,255,.8)] [transform:translateZ(1px)]" />
<Front p={p} i={i} label={label} />
<Back p={p} label={label} />
<span aria-hidden="true" className="pointer-events-none absolute inset-0 overflow-hidden rounded-[18px] opacity-0 [backface-visibility:hidden]">
<span
ref={(el) => void (sheens.current[i] = el)}
className="absolute inset-[-50%] will-change-transform"
style={{ background: "linear-gradient(115deg, transparent 40%, rgba(255,255,255,.55) 50%, transparent 60%)" }}
/>
</span>
</div>
</div>
</div>
))}
</>
)}
</div>
);
}
export default BadgeLine;
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
5 propspeople{ name; role; photo; focus?; bio?; location?; projects?; email?; href? }[]The team.labelstringSmall label on each badge.default "People · Studio"default "People · Studio"heightnumberHeight of the area, px.default 460default 460cardWidthnumberBadge width, px (defaults to fit).classNamestringExtra classes.