Components82 / 118
Index Band
A project index you scroll through a focus band: an endless list in huge condensed italic type, dim, with the row in the band lit and shifted along, its tags, year and picture beside it. Rows crossing the band split in two; the type leans and stretches with speed and the picture swaps through a pixel mosaic.
Project listProject listTypographyTypographyScrollScrollPixel mosaicPixel mosaicSquash & stretchSquash & stretchGSAPGSAP
Scroll, drag or flick the listClick a row to bring it in
Tweak
LIVELIVELook
#e0262b
Motion
0.0s
Usage
Follows your tweaks.
usage.tsx
import { IndexBand } from "@/components/inreact/index-band";
const work = [
{ title: "Northern Lights", tags: ["Film", "Campaign"], year: "2024", image: "/work/lights.jpg", href: "/work/lights" },
{ title: "Slow City", tags: ["Documentary"], year: "2023", image: "/work/slow-city.jpg", href: "/work/slow-city" },
// ...
];
// pass a condensed display face for the full effect (e.g. Anton or Bebas Neue)
export function Work() {
return <IndexBand items={work} height={560} />;
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/index-band.jsonOr copy the source
Install the dependencies, then save this as components/inreact/index-band.tsx.
terminal
npm install gsapcomponents/inreact/index-band.tsx
"use client";
import { gsap } from "gsap";
import { useEffect, useRef, useState } from "react";
/**
* Index Band: a project index you scroll through a focus band.
*
* Your projects as one endless list in huge condensed italic type, dim on a
* dark page. Across the middle runs a focus band: the row inside it lights up
* white and slides along, with its tags and year beside it and its picture on
* the left. Rows crossing the band's edge split in two, half lit and half not.
* Scroll, drag or flick it and the type leans harder and stretches with speed,
* then springs upright as it lands on a row; the picture swaps through a pixel
* mosaic. Point at a dim row and it lights; click it and it comes to the band.
*
* <IndexBand items={[{ title: "Northern Lights", tags: ["Film", "Campaign"], year: "2024", image: "/p/1.jpg" }]} />
*/
export interface IndexItem {
title: string;
tags?: string[];
year?: string;
image: string;
href?: string;
}
export interface IndexBandProps {
items: IndexItem[];
height?: number;
/** Seconds between automatic steps; 0 turns it off. */
autoplay?: number;
/** The display face (condensed bold works best). */
fontFamily?: string;
/** Accent for the band's hairlines. */
accent?: string;
background?: 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));
const FACE = `"Anton", "Bebas Neue", Impact, "Haettenschweiler", "Arial Narrow Bold", "Arial Narrow", sans-serif`;
export function IndexBand({ items, height = 520, autoplay = 0, fontFamily = FACE, accent = "#e0262b", background = "#121212", onChange, className }: IndexBandProps) {
const rootRef = useRef<HTMLDivElement>(null);
const baseRows = useRef<(HTMLDivElement | null)[]>([]);
const litRows = useRef<(HTMLDivElement | null)[]>([]);
const canvasRef = useRef<HTMLCanvasElement>(null);
const [active, setActive] = useState(0);
const [hover, setHover] = useState(-1);
const [W, setW] = useState(0);
const n = items.length;
// enough copies to fill the height however short the list is
const copies = Math.max(1, Math.ceil(13 / Math.max(1, n)));
const rows = Array.from({ length: n * copies }, (_, i) => i % n);
const R = rows.length;
const onChangeRef = useRef(onChange);
onChangeRef.current = onChange;
const H = height;
const rowH = Math.round(H / 7.2);
// the type fills the row, but never runs off the side
const longest = items.reduce((m, x) => Math.max(m, x.title.length), 1);
const leftGuess = Math.round(Math.min(H * 0.42, (W || H) * 0.3));
// condensed caps run about half an em wide; the lit (shifted) title ends before the year
const fitW = W ? (W * 0.78 - leftGuess - rowH * 0.9) / (longest * 0.5) : rowH;
const fs = Math.round(clamp(10, rowH * 0.92, fitW));
const mid = Math.round(H / 2);
const shift = Math.round(rowH * 0.9);
useEffect(() => {
const el = rootRef.current;
if (!el) return;
const ro = new ResizeObserver(([e]) => setW(e.contentRect.width));
ro.observe(el);
return () => ro.disconnect();
}, []);
useEffect(() => {
const root = rootRef.current, canvas = canvasRef.current;
if (!root || !canvas || !n) return;
const still = reduced();
const st = { p: 0, v: 0, target: 0, drag: false, lean: 0, vlean: 0, lastP: 0, vel: 0 };
let current = 0;
const last = rows.map(() => "");
// the picture: a small canvas that swaps through a pixel mosaic
const ctx = canvas.getContext("2d")!;
const imgs = items.map((it) => {
const im = new Image();
im.src = it.image;
return im;
});
const cw = canvas.width, chh = canvas.height;
const small = document.createElement("canvas");
const sctx = small.getContext("2d")!;
const drawCover = (im: HTMLImageElement, block: number) => {
if (!im.complete || !im.naturalWidth) return false;
const sw = Math.max(1, Math.round(cw / block)), sh = Math.max(1, Math.round(chh / block));
small.width = sw;
small.height = sh;
const z = Math.max(sw / im.naturalWidth, sh / im.naturalHeight);
const w = im.naturalWidth * z, h = im.naturalHeight * z;
sctx.imageSmoothingEnabled = true;
sctx.drawImage(im, (sw - w) / 2, (sh - h) / 2, w, h);
ctx.imageSmoothingEnabled = block <= 1.01;
ctx.clearRect(0, 0, cw, chh);
ctx.drawImage(small, 0, 0, sw, sh, 0, 0, cw, chh);
return true;
};
const pic = { from: 0, to: 0, t: 1 };
let picTween: gsap.core.Tween | null = null;
const paint = () => {
// first half: the old picture breaks into blocks; second half: the new one resolves
const t = pic.t;
if (t < 0.5) drawCover(imgs[pic.from], 1 + Math.pow(t / 0.5, 1.5) * 26);
else drawCover(imgs[pic.to], 1 + Math.pow((1 - t) / 0.5, 1.5) * 26);
};
imgs[0].onload = () => paint();
paint();
const swapTo = (i: number) => {
picTween?.kill();
pic.from = pic.t < 0.5 ? pic.from : pic.to;
pic.to = i;
if (still) {
pic.t = 1;
paint();
return;
}
pic.t = 0;
picTween = gsap.to(pic, { t: 1, duration: 0.55, ease: "steps(10)", onUpdate: paint });
};
const settle = (to: number) => {
st.target = to;
const i = ((Math.round(to) % n) + n) % n;
if (i !== current) {
current = i;
setActive(i);
swapTo(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 = 70, c = 2 * 0.72 * Math.sqrt(k);
st.v += (k * (st.target - st.p) - c * st.v) * h;
st.p += st.v * h;
}
}
}
const raw = (st.p - st.lastP) / Math.max(dt, 1e-3);
st.lastP = st.p;
st.vel += (raw - st.vel) * 0.3;
// the type leans harder and stretches with speed, and springs upright as it lands
const want = still ? 0 : clamp(-14, 14, st.vel * 2.2);
const kl = 220, cl = 2 * 0.32 * Math.sqrt(kl);
st.vlean += (kl * (want - st.lean) - cl * st.vlean) * dt;
st.lean += st.vlean * dt;
const stretch = still ? 0 : clamp(0, 0.18, Math.abs(st.vel) * 0.025);
// live "current" follows the band, even mid-scroll
const live = ((Math.round(st.p) % n) + n) % n;
if (live !== current && (st.drag || Math.abs(st.v) > 0.5)) {
current = live;
setActive(live);
swapTo(live);
}
for (let r = 0; r < R; r++) {
let d = (((r - st.p) % R) + R) % R;
if (d > R / 2) d -= R;
const y = mid + d * rowH - rowH / 2;
const sk = -10 - st.lean;
const tr = `translate3d(0,${y.toFixed(2)}px,0) skewX(${sk.toFixed(2)}deg) scaleY(${(1 + stretch).toFixed(4)})`;
if (tr !== last[r]) {
const b = baseRows.current[r], l = litRows.current[r];
if (b) b.style.transform = tr;
if (l) l.style.transform = tr;
last[r] = tr;
}
}
};
gsap.ticker.add(tick);
// autoplay, until someone takes over
let took = false;
const auto = autoplay > 0 && !still ? window.setInterval(() => !took && !st.drag && settle(Math.round(st.target) + 1), autoplay * 1000) : 0;
// drag / flick / wheel
let sy = 0, sp = 0, ly = 0, lt = 0, moved = 0, id = -1, vv = 0;
const onDown = (e: PointerEvent) => {
if (e.button !== 0) return;
if (e.isTrusted) took = true;
id = e.pointerId;
st.drag = true;
sy = ly = e.clientY;
sp = st.p;
lt = performance.now();
moved = 0;
vv = 0;
};
const rowAt = (clientY: number) => {
const r = root.getBoundingClientRect();
const d = Math.round((clientY - r.top - mid) / rowH + st.p);
return ((d % n) + n) % n;
};
const onMove = (e: PointerEvent) => {
if (!st.drag) {
setHover(rowAt(e.clientY));
return;
}
if (e.pointerId !== id) return;
const dy = e.clientY - sy;
moved = Math.max(moved, Math.abs(dy));
if (moved > 4 && !root.hasPointerCapture(e.pointerId)) {
try {
root.setPointerCapture(e.pointerId);
} catch {
/* capture is a nicety */
}
}
const now = performance.now();
vv = vv * 0.6 + (-(e.clientY - ly) / rowH / Math.max(1, now - lt)) * 1000 * 0.4;
ly = e.clientY;
lt = now;
st.p = sp - dy / rowH;
};
const onUp = (e: PointerEvent) => {
if (e.pointerId !== id) return;
id = -1;
if (!st.drag) return;
st.drag = false;
st.v = vv;
if (moved < 5) {
// a click: that row comes to the band (or opens, if it's already there)
const r = root.getBoundingClientRect();
const d = Math.round((e.clientY - r.top - mid) / rowH);
if (d === 0 && items[current]?.href) window.location.href = items[current].href!;
else settle(Math.round(st.p) + d);
return;
}
settle(Math.round(st.p + clamp(-6, 6, vv * 0.3)));
};
const onLeave = () => setHover(-1);
let wacc = 0, wlock = 0;
const onWheel = (e: WheelEvent) => {
e.preventDefault();
took = true;
const now = performance.now();
wacc += e.deltaY;
if (now < wlock) return;
if (Math.abs(wacc) > 30) {
settle(Math.round(st.target) + Math.sign(wacc) * Math.min(3, Math.max(1, Math.round(Math.abs(wacc) / 120))));
wacc = 0;
wlock = now + 90;
}
};
const onKey = (e: KeyboardEvent) => {
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
e.preventDefault();
took = true;
settle(Math.round(st.target) + (e.key === "ArrowDown" ? 1 : -1));
};
root.addEventListener("pointerdown", onDown);
root.addEventListener("pointermove", onMove);
root.addEventListener("pointerup", onUp);
root.addEventListener("pointercancel", onUp);
root.addEventListener("pointerleave", onLeave);
root.addEventListener("wheel", onWheel, { passive: false });
root.addEventListener("keydown", onKey);
return () => {
gsap.ticker.remove(tick);
picTween?.kill();
if (auto) window.clearInterval(auto);
root.removeEventListener("pointerdown", onDown);
root.removeEventListener("pointermove", onMove);
root.removeEventListener("pointerup", onUp);
root.removeEventListener("pointercancel", onUp);
root.removeEventListener("pointerleave", onLeave);
root.removeEventListener("wheel", onWheel);
root.removeEventListener("keydown", onKey);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [n, items, autoplay, H, rowH, mid, R]);
const left = Math.round(Math.min(H * 0.42, (W || H) * 0.3)); // where the type starts (room for the picture)
const picW = Math.round(rowH * 1.55), picH = Math.round(rowH * 1.02);
const it = items[active];
// tags show only if their longest line fits between the picture and the title
const tagFs = Math.max(7, Math.round(Math.min(rowH * 0.11, fs * 0.16)));
const tagLen = items.reduce((m, x) => Math.max(m, ...(x.tags ?? [""]).map((t) => t.length)), 0);
const tagsFit = left + shift - Math.round(rowH * 0.14) - tagLen * tagFs * 0.62 > Math.round(H * 0.06) + 8 + picW + 6;
const rowStyle = { height: rowH, fontSize: fs, lineHeight: `${rowH}px`, fontFamily, transformOrigin: `${left}px 50%` };
return (
<div
ref={rootRef}
tabIndex={0}
role="listbox"
aria-label="Projects"
aria-activedescendant={`ib-${active}`}
className={["relative w-full cursor-grab touch-none overflow-hidden outline-none select-none active:cursor-grabbing", className].filter(Boolean).join(" ")}
style={{ height: H, background }}
>
{/* faint row rules */}
<div aria-hidden="true" className="pointer-events-none absolute inset-0" style={{ backgroundImage: `repeating-linear-gradient(180deg, transparent 0 ${rowH - 1}px, rgba(255,255,255,.05) ${rowH - 1}px ${rowH}px)`, backgroundPosition: `0 ${mid - rowH / 2}px` }} />
{/* the dim list */}
{rows.map((i, r) => (
<div
key={`b${r}`}
ref={(el) => void (baseRows.current[r] = el)}
aria-hidden="true"
className="absolute top-0 left-0 w-full uppercase whitespace-nowrap will-change-transform"
style={{ ...rowStyle, paddingLeft: left, color: hover === i ? "rgba(255,255,255,.9)" : "rgba(255,255,255,.13)", transition: "color .25s ease" }}
>
{items[i].title}
</div>
))}
{/* the band: the same list, lit and shifted, clipped to the middle row */}
<div aria-hidden="true" className="pointer-events-none absolute inset-0" style={{ clipPath: `inset(${mid - rowH / 2}px 0 ${H - mid - rowH / 2}px 0)` }}>
<div className="absolute inset-0" style={{ background }} />
{rows.map((i, r) => (
<div
key={`l${r}`}
ref={(el) => void (litRows.current[r] = el)}
className="absolute top-0 left-0 w-full text-white uppercase whitespace-nowrap will-change-transform"
style={{ ...rowStyle, paddingLeft: left + shift }}
>
{items[i].title}
</div>
))}
</div>
{/* band furniture: hairlines, picture, tags, year, ring */}
<div aria-hidden="true" className="pointer-events-none absolute inset-x-0" style={{ top: mid - rowH / 2, height: rowH }}>
<div className="absolute top-1/2 h-px" style={{ left: 0, width: Math.round(H * 0.06), background: accent }} />
<canvas
ref={canvasRef}
width={picW * 2}
height={picH * 2}
className="absolute top-1/2 -translate-y-1/2"
style={{ left: Math.round(H * 0.06) + 8, width: picW, height: picH }}
/>
<div
className="absolute top-1/2 -translate-y-1/2 text-right font-mono uppercase leading-[1.35] text-white/80"
// ends just before the lit title, whatever the size
style={{ right: (W || H) - (left + shift) + Math.round(rowH * 0.14), fontSize: tagFs }}
>
{/* tags only when there's room for them beside the picture */}
{(tagsFit ? (it?.tags ?? []) : []).map((t) => (
<div key={t}>{t}</div>
))}
</div>
<div className="absolute top-1/2 h-px" style={{ right: Math.round(H * 0.06), width: Math.round(H * 0.2), background: accent }} />
{it?.year && (
<div className="absolute top-1/2 -translate-y-1/2 font-mono text-white/80" style={{ right: Math.round(H * 0.28), fontSize: Math.max(8, Math.round(rowH * 0.11)) }}>
{it.year}
</div>
)}
<div className="absolute top-1/2 size-[9px] -translate-y-1/2 rounded-full border border-white/70" style={{ right: Math.round(H * 0.03) }} />
</div>
{/* for screen readers */}
<ul className="sr-only">
{items.map((x, i) => (
<li key={i} id={`ib-${i}`} role="option" aria-selected={i === active}>
{x.title} {x.tags?.join(", ")} {x.year}
</li>
))}
</ul>
</div>
);
}
export default IndexBand;
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; tags?: string[]; year?: string; image: string; href?: string }[]The projects.heightnumberHeight, px.default 520default 520fontFamilystringDisplay face (a condensed bold works best).accentstringThe band's hairlines.default "#e0262b"default "#e0262b"autoplaynumberSeconds between automatic steps; 0 is off.default 0default 0backgroundstringBackground colour.default "#121212"default "#121212"onChange(index: number) => voidCalled when the row in the band changes.classNamestringExtra classes.