Components76 / 118
Arc Carousel
Cards hanging from the rim of a big turning wheel, tilting with the curve and stepping one at a time. Turn it (drag, flick, click, swipe) and every card swings behind the motion like a tag on a ring, overshoots and settles with a wobble. Point at a card and it pops out of the arc.
CarouselCarouselCardsCardsDragDragPendulumPendulumSquash & stretchSquash & stretchGSAPGSAP
Drag or flick the wheelClick a card to bring it round
Tweak
LIVELIVECards
200px
Motion
2.6s
Usage
Follows your tweaks.
usage.tsx
import { ArcCarousel } from "@/components/inreact/arc-carousel";
const stories = [
{ title: "Studio", text: "Tools and rituals for the hours you make things.", image: "/photos/studio.jpg", href: "/studio" },
{ title: "Field notes", text: "Short reads from people who build in the open.", image: "/photos/notes.jpg", href: "/notes" },
// ...
];
export function Stories() {
return <ArcCarousel items={stories} height={460} />;
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/arc-carousel.jsonOr copy the source
Install the dependencies, then save this as components/inreact/arc-carousel.tsx.
terminal
npm install gsapcomponents/inreact/arc-carousel.tsx
"use client";
import { gsap } from "gsap";
import { useEffect, useRef, useState } from "react";
/**
* Arc Carousel: cards hanging from a big turning wheel.
*
* Cards ride the rim of a large wheel, tilting with the curve, and the wheel
* steps one card at a time. The cards hang from it like tags on a ring: turn
* it (drag, flick, click a card, swipe a trackpad or use the arrow keys) and
* every card swings behind the motion, overshoots and settles with a wobble,
* stretching along the curve with speed. Point at one and it pops out of the
* arc. It steps along by itself until you take over.
*
* <ArcCarousel items={[{ title: "Coast", text: "...", image: "/coast.jpg" }]} />
*/
export interface ArcCarouselItem {
title: string;
text: string;
/** A photo; it's blurred into a soft backdrop. */
image: string;
href?: string;
}
export interface ArcCarouselProps {
items: ArcCarouselItem[];
/** Width of the area it fills, px (defaults to its container). */
width?: number;
height?: number;
/** Card width, px. */
cardWidth?: number;
/** Seconds between steps; 0 turns it off. */
autoplay?: number;
cta?: 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));
function Burst({ s }: { s: number }) {
return (
<svg viewBox="0 0 24 24" width={s} height={s} aria-hidden="true" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round">
<path d="M12 2.8 13.9 8l5.5-1.6-3.3 4.6 4.1 3.9-5.6.6.2 5.7-4-3.9-4.3 3.7.4-5.7-5.6-.8 4.2-3.8L2.4 6.3 7.9 8Z" />
</svg>
);
}
export function ArcCarousel({ items, width, height = 440, cardWidth, autoplay = 2.6, cta = "Read more", onChange, className }: ArcCarouselProps) {
const rootRef = useRef<HTMLDivElement>(null);
const outers = useRef<(HTMLDivElement | null)[]>([]);
const inners = useRef<(HTMLDivElement | null)[]>([]);
const [W, setW] = useState(width ?? 0);
const n = items.length;
const onChangeRef = useRef(onChange);
onChangeRef.current = onChange;
useEffect(() => {
if (width) return setW(width);
const el = rootRef.current;
if (!el) return;
const ro = new ResizeObserver(([e]) => setW(e.contentRect.width));
ro.observe(el);
return () => ro.disconnect();
}, [width]);
const CW = Math.round(cardWidth ?? clamp(140, 230, W * 0.2));
const CH = Math.round(CW * 1.42);
// every card is laid out once at a design size and scaled as a whole, so
// small cards keep exactly the same proportions (text never wraps or spills)
const BW = 220, BH = Math.round(BW * 1.42), K = CW / BW;
useEffect(() => {
const root = rootRef.current;
if (!root || !W || !n) return;
const still = reduced();
const R = Math.max(W * 1.05, CW * 4.2); // the wheel's radius
const gap = (CW * 1.12) / R; // radians between cards
const cx = W / 2, cy = height * 0.09 + CH / 2 + R; // the wheel's hub, far below (the top card sits near the top)
const st = { p: 0, v: 0, target: 0, drag: false };
// each card: a pendulum swing (lags behind the turn) and a hover pop
const cards = items.map((_, k) => ({ sw: 0, vs: 0, h: 0, vh: 0, th: 0, k: 150 + (k % 3) * 35 }));
let current = 0;
let lastV = 0;
const last = items.map(() => "");
const settle = (to: number) => {
st.target = to;
const idx = ((Math.round(to) % n) + n) % n;
if (idx !== current) {
current = idx;
onChangeRef.current?.(idx);
}
};
const tick = (_t: number, ms: number) => {
const dt = Math.min(ms / 1000, 1 / 30);
const h = dt / 2;
for (let i = 0; i < 2; i++) {
if (!st.drag) {
if (still) {
st.p = st.target;
st.v = 0;
} else {
const k = 70, c = 2 * 0.78 * Math.sqrt(k);
st.v += (k * (st.target - st.p) - c * st.v) * h;
st.p += st.v * h;
}
}
}
const acc = (st.v - lastV) / Math.max(dt, 1e-3);
lastV = st.v;
const speed = Math.abs(st.v);
for (let k = 0; k < n; k++) {
const c = cards[k];
// hanging: the swing is pushed by the wheel's acceleration and wobbles back
if (still) {
c.sw = 0;
c.h = c.th;
} else {
const kk = c.k, cc = 2 * 0.2 * Math.sqrt(kk);
c.vs += (-kk * c.sw - cc * c.vs - acc * 9) * dt;
c.sw = clamp(-28, 28, c.sw + c.vs * dt);
const kh = 260, ch = 2 * 0.45 * Math.sqrt(kh);
c.vh += (kh * (c.th - c.h) - ch * c.vh) * dt;
c.h += c.vh * dt;
}
// where it sits on the wheel (wrapped, so it loops forever)
let d = (((k - st.p) % n) + n) % n;
if (d > n / 2) d -= n;
const a = d * gap;
const rr = R + c.h * CH * 0.14;
const x = cx + Math.sin(a) * rr - BW / 2, y = cy - Math.cos(a) * rr - BH / 2;
const far = Math.abs(d);
const op = far > n / 2 - 0.6 ? Math.max(0, (n / 2 - far) / 0.6) : 1;
const stretch = still ? 0 : Math.min(0.08, speed * 0.03);
const sc = 1 + c.h * 0.05;
const outer = `translate3d(${x.toFixed(2)}px,${y.toFixed(2)}px,0) rotate(${((a * 180) / Math.PI).toFixed(3)}deg) scale(${K.toFixed(4)})`;
const inner = `rotate(${c.sw.toFixed(3)}deg) scale(${(sc * (1 + stretch)).toFixed(4)},${(sc / (1 + stretch)).toFixed(4)})`;
const key = `${outer}|${inner}|${op.toFixed(2)}`;
if (key !== last[k]) {
const o = outers.current[k], i = inners.current[k];
if (o) {
o.style.transform = outer;
o.style.opacity = op.toFixed(2);
o.style.zIndex = String(100 - Math.round(far * 4) + Math.round(c.h * 10));
}
if (i) i.style.transform = inner;
last[k] = key;
}
}
};
gsap.ticker.add(tick);
// autoplay: one card at a time, until someone takes over
let paused = false, took = false;
const auto = autoplay > 0 && !still ? window.setInterval(() => !paused && !took && !st.drag && settle(Math.round(st.target) + 1), autoplay * 1000) : 0;
// drag / flick
let sx = 0, sp = 0, lx = 0, lt = 0, moved = 0, id = -1;
const pxPerCard = gap * R;
const onDown = (e: PointerEvent) => {
if (e.button !== 0) return;
if (e.isTrusted) took = true;
id = e.pointerId;
st.drag = true;
sx = lx = e.clientX;
sp = st.p;
lt = performance.now();
moved = 0;
};
const onMove = (e: PointerEvent) => {
if (e.pointerId !== id || !st.drag) return;
const dx = e.clientX - sx;
moved = Math.max(moved, Math.abs(dx));
if (moved > 4 && !root.hasPointerCapture(e.pointerId)) {
try {
root.setPointerCapture(e.pointerId);
} catch {
/* capture is a nicety; never let it stop the drag */
}
}
const now = performance.now(), ddt = Math.max(1, now - lt) / 1000;
const vNow = -(e.clientX - lx) / pxPerCard / ddt;
st.v = st.v * 0.6 + vNow * 0.4;
lx = e.clientX;
lt = now;
st.p = sp - dx / pxPerCard;
};
const onUp = (e: PointerEvent) => {
if (e.pointerId !== id) return;
id = -1;
if (!st.drag) return;
st.drag = false;
if (moved < 5) {
// a click: that card comes round to the top
const card = (e.target as HTMLElement).closest<HTMLElement>("[data-arc-card]");
if (card && !(e.target as HTMLElement).closest("a,button")) {
const k = Number(card.dataset.arcCard);
let d = (((k - st.p) % n) + n) % n;
if (d > n / 2) d -= n;
settle(Math.round(st.p + d));
} else settle(Math.round(st.p));
return;
}
settle(Math.round(st.p + clamp(-3, 3, st.v * 0.3)));
};
root.addEventListener("pointerdown", onDown);
root.addEventListener("pointermove", onMove);
root.addEventListener("pointerup", onUp);
root.addEventListener("pointercancel", onUp);
// hover: the card under the pointer pops out of the arc
const onOver = (e: PointerEvent) => {
const card = (e.target as HTMLElement).closest<HTMLElement>("[data-arc-card]");
const k = card ? Number(card.dataset.arcCard) : -1;
cards.forEach((c, i) => (c.th = i === k ? 1 : 0));
};
// only a real pointer resting on it pauses the autoplay
const onEnter = (e: PointerEvent) => void (e.isTrusted && (paused = true));
const onLeave = () => {
paused = false;
cards.forEach((c) => (c.th = 0));
};
root.addEventListener("pointerover", onOver);
root.addEventListener("pointerenter", onEnter);
root.addEventListener("pointerleave", onLeave);
// sideways trackpad swipes
let acc2 = 0, lock = 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();
took = true;
const now = performance.now();
if (now < lock) return;
acc2 += dx;
if (Math.abs(acc2) > 40) {
settle(Math.round(st.target) + Math.sign(acc2));
acc2 = 0;
lock = now + 320;
}
};
root.addEventListener("wheel", onWheel, { passive: false });
const onKey = (e: KeyboardEvent) => {
if (e.key !== "ArrowRight" && e.key !== "ArrowLeft") return;
e.preventDefault();
took = true;
settle(Math.round(st.target) + (e.key === "ArrowRight" ? 1 : -1));
};
root.addEventListener("keydown", onKey);
return () => {
gsap.ticker.remove(tick);
if (auto) window.clearInterval(auto);
root.removeEventListener("pointerdown", onDown);
root.removeEventListener("pointermove", onMove);
root.removeEventListener("pointerup", onUp);
root.removeEventListener("pointercancel", onUp);
root.removeEventListener("pointerover", onOver);
root.removeEventListener("pointerenter", onEnter);
root.removeEventListener("pointerleave", onLeave);
root.removeEventListener("wheel", onWheel);
root.removeEventListener("keydown", onKey);
};
}, [W, height, CW, CH, K, BW, BH, n, items, autoplay]);
return (
<div
ref={rootRef}
tabIndex={0}
role="region"
aria-roledescription="carousel"
aria-label="Cards"
className={["relative cursor-grab touch-pan-y overflow-hidden outline-none select-none active:cursor-grabbing", className].filter(Boolean).join(" ")}
style={{
width: width ?? "100%",
height,
// the far cards fade away at the bottom instead of being cut off
WebkitMaskImage: "linear-gradient(180deg, #000 72%, transparent 100%)",
maskImage: "linear-gradient(180deg, #000 72%, transparent 100%)",
}}
>
{W > 0 &&
items.map((it, k) => (
<div
key={k}
ref={(el) => void (outers.current[k] = el)}
data-arc-card={k}
role="group"
aria-roledescription="slide"
aria-label={`${k + 1} of ${n}: ${it.title}`}
className="absolute top-0 left-0 will-change-transform"
style={{ width: BW, height: BH }}
>
<div
ref={(el) => void (inners.current[k] = el)}
// its own layer: the swing and stretch never redraw the blurred photo
className="relative h-full w-full overflow-hidden will-change-transform"
style={{
transformOrigin: "50% 0%",
borderRadius: Math.round(BW * 0.085),
boxShadow: "0 1px 2px rgba(20,20,30,.06), 0 8px 20px rgba(20,20,30,.08), 0 22px 44px rgba(20,20,30,.08)",
}}
>
{/* the photo, blurred into a soft pastel backdrop */}
<img
src={it.image}
alt=""
draggable={false}
className="pointer-events-none absolute inset-0 h-full w-full scale-[1.35] object-cover"
style={{ filter: `blur(${Math.round(BW * 0.1)}px) saturate(.85) brightness(1.18)` }}
/>
{/* a milky wash keeps it pastel and the text readable */}
<div className="absolute inset-0" style={{ background: "linear-gradient(180deg, rgba(255,255,255,.72) 0%, rgba(255,255,255,.5) 50%, rgba(255,255,255,.22) 100%)" }} />
<div className="relative flex h-full flex-col items-center text-center text-[#16161a]" style={{ padding: `${Math.round(BW * 0.1)}px ${Math.round(BW * 0.09)}px` }}>
<Burst s={Math.round(BW * 0.16)} />
<div className="mt-[6%] font-medium tracking-[-0.01em]" style={{ fontSize: Math.round(BW * 0.12) }}>
{it.title}
</div>
<p className="mt-[4%] leading-[1.3] text-[#16161a]/80" style={{ fontSize: Math.round(BW * 0.065) }}>
{it.text}
</p>
<a
href={it.href ?? "#"}
onClick={(e) => !it.href && e.preventDefault()}
className="mt-auto rounded-[10px] bg-white px-[1em] py-[.55em] whitespace-nowrap font-mono tracking-[0.08em] text-[#16161a] uppercase shadow-[0_1px_2px_rgba(0,0,0,.08)] transition-transform duration-300 hover:scale-[1.05] active:scale-95"
style={{ fontSize: Math.round(BW * 0.06) }}
>
{cta}
</a>
</div>
</div>
</div>
))}
</div>
);
}
export default ArcCarousel;
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{ title: string; text: string; image: string; href?: string }[]The cards (the photo is blurred into a soft backdrop).cardWidthnumberCard width, px (defaults to 20% of the width).heightnumberHeight of the area, px.default 440default 440widthnumberWidth, px (defaults to its container).autoplaynumberSeconds between steps; 0 turns it off.default 2.6default 2.6ctastringButton label.default "Read more"default "Read more"onChange(index: number) => voidCalled when the top card changes.classNamestringExtra classes.