Impeccable

Spotlight Ticker

A gliding row of pictures stops as the one you point at grows, and a click opens its story. Use it on a home or work page with 5 to 10 projects.

TickerMarqueeHoverNo extra packagesLight + darkMobile
npx shadcn@latest add https://impeccable-ui.com/r/spotlight-ticker.json
Point at a picture to stop the row, then click it to open its story. Click outside, press Esc or the X to close. On a phone, tap a picture.

Run it in a project set up with shadcn. No other packages needed. Or open and copy the file into components/ui/spotlight-ticker.tsx.

Prompts

Paste one into Claude Code, Cursor or any AI coding tool. Install adds this exact ticker and asks only where it goes and which pictures it shows. Blend asks four short questions (where and which pictures, the direction, the speed, and the size and corners), then fits it to your brand without changing how it moves.

# Spotlight Ticker

A 1-file React component from Impeccable. Add it to this project so it works and looks exactly like the source below, in the one place I choose, and change nothing else.

A row of square pictures that glides sideways forever, like a ticker. When I point at a picture the row stops, that picture grows to 1.8 times its size and the others dim. When I click it, the others fade away, the picture glides to the left and its story comes in beside it: a heading, a few short bullet points and one button. It closes like a pop up (the X, Esc, a click on the picture or a click anywhere outside), the picture glides back and the row carries on. On a phone one tap opens the story.

## Before you build: one question

Look through this project first: pages that show work, projects, products, features or case studies (a home page, a portfolio or work section, a showcase or "what we make" strip), the pictures they already have, and where their words and links come from. Then ask me this in one message and wait for my answer:

- **Where should it go, and which pictures does it show?** Suggest the 1–3 spots it fits best from my code. For each one, name the 5–10 pictures you would use, with the heading, 2–4 short bullet points and the button (words and link) for each, taken from my real content. I can pick one or name another.
  *Why: each picture opens a short story with one button, so it belongs where people browse things they might want to open, and it needs real words to show.*

Ask nothing else. If I say *skip*, use the best suggestion.

## Keep it as it is

The gliding row, the stop with one picture growing while the others dim, the glide into the story with its line-by-line drop from above, the pop up close and all their timing are the design. Keep them exactly as in the source. If something doesn't fit my project, tell me instead of changing it.

- Add only the component file and the one place I picked. If it replaces an existing strip or grid there, keep that spot's data and links and remove only the old markup. Don't add packages, change other files, or restyle anything.
- Don't add the demo parts from the Impeccable website: its eight item pictures and their stories, the gray panel round it, and the home page's TV.

## Fastest path

If this project has a `components.json` (shadcn), run `npx shadcn@latest add https://impeccable-ui.com/r/spotlight-ticker.json`.
If the command succeeds, only fix import paths to match this project and skip ahead. If it fails or there is no `components.json`, build it by hand as below.

## Build it

- Stack: React 18 or 19 with TypeScript. No other packages: the row moves with one `requestAnimationFrame` loop, the grow and dim are CSS transitions, and the glide uses the browser's own Web Animations API. Its styles sit in a `<style>` tag inside the file.
- JavaScript project? Name the file `spotlight-ticker.jsx` and remove the type annotations; nothing else changes.
- Create this file, in this project's usual place for components:
  - `components/ui/spotlight-ticker.tsx`
- Keep these exports and their names: `SpotlightTicker` (also the default export), `SpotlightTickerProps`, `SpotlightTickerItem`.
- Keep `"use client"` at the top in Next.js App Router projects. In other setups it is harmless.
- Keep the tuning values at the top exactly as written: `ZOOM`, `DIM`, `GAP`, `FOCUS_MS`, `FOCUS_EASE`, `STOP_MS`, `START_MS`, `FADE_MS`, `GLIDE_MS`, `CLOSE_MS`, `GLIDE_EASE`, `TEXT_DELAY`, `TEXT_MS`, `TEXT_DROP`, `TEXT_BLUR`, `TEXT_STAGGER`, `TEXT_OUT_MS`, `EDGE`, `SHADOW_ROOM`, `STACK_AT`, `SMALL_AT`, `SMALL` and the `CSS` block. They are the design and its timing.
- Keep the fallbacks: hover only grows a picture where a real mouse can hover (`(hover: hover) and (pointer: fine)`), touch screens open the story on one tap, phones (under 640px) get pictures at 70% size and the story under the picture, Tab moves picture by picture and Enter opens it, and with `prefers-reduced-motion: reduce` the row stands still and scrolls by hand. The row pauses while it is off screen or the tab is hidden.

## Use it

```tsx
import { SpotlightTicker } from "@/components/ui/spotlight-ticker";

const ITEMS = [
  {
    image: { src: "/showcase/comet-button.webp", alt: "Comet button, a glow racing round its border" },
    title: "Comet button",
    points: ["A glow races round the border while it loads.", "Success lights the whole border, then eases back."],
    cta: { label: "Open component", href: "/docs/comet-button" },
  },
  // one entry per picture, 5 to 10 reads best
];

export function Showcase() {
  return <SpotlightTicker items={ITEMS} aria-label="Our components" />;
}
```

- It fills the width it is given. Give it the full width of its section; it needs about 1.8 times the picture size plus 96px in height (about 384px at the default size), so the grown picture and its shadow have room.
- Pictures are shown square and cropped to fill. Keep each file small (about 500px square, WebP), with real `alt` text. Pictures from another domain must be allowed by the project's Content-Security-Policy (`img-src`).
- `cta` with `href` is a link; use the project's own link component only if plain `href` breaks its routing, then pass `onClick` and navigate there instead.

## How the ticker works

Read this before you touch anything, so you know what the code does and why it must stay as it is.

1. **The row.** The pictures sit in a row with a gap of 15% of their size, copied as many times as it takes to fill the width twice. One animation loop moves the row at `speed` pixels per second (default 32, slow enough to see each picture) and wraps it after one full set, so it never ends. `direction` "left" or "right" sets the way it moves. Both sides of the row fade out softly with a CSS mask (40% of a picture wide, at most 8% of the row), so pictures never get cut off with a hard edge.
2. **Point at a picture.** The row glides to a stop in about 0.45 seconds. The picture grows to 1.8 times its size in 450ms with a gentle start and a long soft landing, rises above its neighbours with a soft shadow, and every other picture drops to 40% opacity, so the one you point at is in focus. Near an edge it steps inward, clear of the faded sides, so it is never cut. The row keeps 48px of room above and below the grown picture, so its shadow is never clipped. Move to another picture and the focus moves with you; leave the row and it eases back to speed over about a second.
3. **Click it.** The other pictures fade out in 420ms. The picture glides from where it is to the left of the story in 720ms (it eases in, travels and settles softly), keeping its corners. Then the story drops in from above, line by line: the close button and heading, each bullet point, then the button, each falling 16px, fading in and losing a 4px blur over 650ms, 110ms apart, starting 520ms in as the picture settles. The block grows if the story is taller than the row.
4. **Close it.** Like a pop up: the X, Esc, a click on the big picture or a click anywhere outside the story. The story lifts away and fades in 240ms while the picture glides back to its place in the row in 620ms, the other pictures fade back in over 420ms, and the row carries on from where it stopped. Focus goes back to the picture.
5. **Phones.** No hover: one tap opens the story straight away. Under 640px the pictures are 70% of `size`, and on narrow blocks (under 560px) the story sits under the picture.
6. **Colors.** The text takes `--foreground` (else `--fg`) and surfaces mix it into `--background` (else `--bg`), so it follows light and dark mode. The button is a quiet outlined pill in those same colors. Only width, height, transform and opacity change while it moves.

## Check

- It type-checks and the page renders with no console errors.
- The row glides at about 32 pixels a second. Pointing at a picture glides it to a stop while that picture grows to 1.8 times its size and the others dim, all in about 0.45 seconds. Clicking glides the picture to the left in 0.72 seconds while its heading, bullet points and button drop in from above line by line, done in about 1.5 seconds. The X, Esc, a click on the picture and a click outside each close it in about 0.75 seconds, and the row carries on.
- It looks right in light and dark mode (check both): text, bullet dots, button and close button read well on each background.
- It works with a finger on a phone: one tap opens the story under the picture, a tap outside closes it, the pictures are smaller, and nothing scrolls sideways.
- With `prefers-reduced-motion: reduce`, the row stands still and scrolls by hand, and nothing glides.
- Nothing else on the site looks or behaves differently.
- Finish with a short report: the files you added or changed, where it's placed, and every place where you had to do something differently from the source, and why.

## Source

The reference implementation. Copy it as-is, then apply only the changes listed above.

### `components/ui/spotlight-ticker.tsx`

```tsx
"use client";

/**
 * Spotlight Ticker, from Impeccable.
 *
 * A row of pictures that glides sideways forever, like a ticker. Point at a
 * picture and the row stops, that picture grows and the others dim, so it is
 * the one in focus. Click it and the others fade away while the picture glides
 * to the left and its story comes in beside it: a heading, a few short bullet
 * points and one button. It works like a pop up: close it with the X, Esc, a
 * click on the picture or a click anywhere outside the story, and the picture glides back, the row returns and carries on from where it stopped.
 *
 * Touch screens have no hover, so one tap opens the story straight away.
 * Reduced motion: the row stands still and scrolls by hand, nothing glides.
 *
 * Colors come from your theme: the text from --foreground (else --fg), the page
 * from --background (else --bg), so it follows light and dark mode.
 * One file, React only, no packages.
 */

import {
  useCallback,
  useEffect,
  useLayoutEffect,
  useRef,
  useState,
  type CSSProperties,
  type MouseEvent as ReactMouseEvent,
} from "react";

export type SpotlightTickerItem = {
  /** The picture. Shown square. alt is read by screen readers. */
  image: { src: string; alt: string };
  /** The heading in the story. */
  title: string;
  /** The story, as short bullet points. Two to four reads best. */
  points: string[];
  /** The one button under the points. With href it is a link, with only onClick a button. */
  cta?: {
    label: string;
    href?: string;
    /** Link target, like "_blank" (then rel="noopener noreferrer" is added). */
    target?: string;
    onClick?: (event: ReactMouseEvent<HTMLElement>) => void;
  };
};

export type SpotlightTickerProps = {
  /** The pictures and their stories, in order. */
  items: SpotlightTickerItem[];
  /** Which way the row moves. */
  direction?: "left" | "right";
  /** How fast the row moves, in pixels per second (like most marquees). 32 lets people read each picture; 50 is brisk, 80 is fast. */
  speed?: number;
  /** Side of each picture at rest, in px. Smaller screens shrink it. */
  size?: number;
  /** Corner radius of the pictures, in px. */
  radius?: number;
  className?: string;
  style?: CSSProperties;
  "aria-label"?: string;
};

/* ---------- the design: keep as written ---------- */

const ZOOM = 1.8; // the picture in focus grows to 1.8 times its size
const DIM = 0.4; // the others drop to 40% opacity
const GAP = 0.15; // space between pictures, as a share of their size
const FOCUS_MS = 450; // grow and dim: slow enough to feel calm, never snappy
const FOCUS_EASE = "cubic-bezier(.22,1,.36,1)"; // gentle start, long soft landing
const STOP_MS = 450; // the row glides to a stop in about this time
const START_MS = 1000; // and takes its time to get going again
const FADE_MS = 420; // the other pictures fade out (and back in)
const GLIDE_MS = 720; // the picture glides to the story
const CLOSE_MS = 620; // and back home on close
const GLIDE_EASE = "cubic-bezier(.4,0,.2,1)"; // eases in, travels, settles softly
const TEXT_DELAY = 520; // the story starts to drop in as the picture settles
const TEXT_MS = 650; // each line drops from above and comes into focus
const TEXT_DROP = 16; // px each line falls
const TEXT_BLUR = 4; // px of soft blur it loses as it lands
const TEXT_STAGGER = 110; // line by line, top to bottom
const TEXT_OUT_MS = 240; // on close the story lifts away first
const EDGE = 0.4; // the row fades out at both sides over 40% of a picture (at most 8% of the row), never a hard cut
const SHADOW_ROOM = 48; // px above and below the grown picture, so its shadow is never clipped
const STACK_AT = 560; // px: narrower than this, the story sits under the picture
const SMALL_AT = 640; // px: on screens narrower than this (phones), pictures are 70% of size
const SMALL = 0.7;

const CSS = `
.spt { --spt-fg: var(--foreground, var(--fg, CanvasText)); --spt-bg: var(--background, var(--bg, Canvas));
  position: relative; width: 100%; box-sizing: border-box; color: var(--spt-fg); transition: height 600ms ${GLIDE_EASE}; }
.spt *, .spt *::before { box-sizing: border-box; }
.spt-view { position: relative; overflow: hidden; height: var(--spt-h); touch-action: pan-y pinch-zoom;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--spt-fade), #000 calc(100% - var(--spt-fade)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--spt-fade), #000 calc(100% - var(--spt-fade)), transparent); }
.spt[data-still="true"] .spt-view { overflow-x: auto; scrollbar-width: none; touch-action: auto; }
.spt[data-still="true"] .spt-view::-webkit-scrollbar { display: none; }
.spt-track { position: absolute; left: 0; top: 0; bottom: 0; display: flex; align-items: center; will-change: transform; }
.spt[data-still="true"] .spt-track { position: relative; height: 100%; will-change: auto; }
.spt-slot { position: relative; flex: none; height: 100%; }
.spt-card { position: absolute; left: 50%; top: 50%; width: var(--spt-s); height: var(--spt-s); transform: translate(-50%, -50%);
  margin: 0; padding: 0; border: 0; background: color-mix(in oklab, var(--spt-fg) 8%, var(--spt-bg)); border-radius: var(--spt-r);
  overflow: hidden; cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; z-index: 1;
  transition: width ${FOCUS_MS}ms ${FOCUS_EASE}, height ${FOCUS_MS}ms ${FOCUS_EASE}, transform ${FOCUS_MS}ms ${FOCUS_EASE},
    opacity ${FOCUS_MS}ms ${FOCUS_EASE}, box-shadow ${FOCUS_MS}ms ${FOCUS_EASE}; }
.spt-card::after, .spt-pic::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--spt-fg) 9%, transparent); z-index: 1; }
.spt-card img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; display: block;
  pointer-events: none; -webkit-user-drag: none; user-select: none; }
.spt-card:focus-visible, .spt-card[data-hot="true"]:focus-visible { box-shadow: 0 0 0 2px var(--spt-bg), 0 0 0 4px color-mix(in oklab, var(--spt-fg) 55%, transparent); }
/* One picture in focus: it grows (and steps inward at the edges), the others dim. */
.spt[data-hot="true"] .spt-card { opacity: ${DIM}; }
.spt-card[data-hot="true"] { opacity: 1 !important; z-index: 2; width: calc(var(--spt-s) * ${ZOOM}); height: calc(var(--spt-s) * ${ZOOM});
  transform: translate(calc(-50% + var(--spt-dx, 0px)), -50%); box-shadow: 0 18px 40px -22px rgba(0,0,0,.45); }
/* Closing: the others come back to full strength while the picture glides home. */
.spt[data-closing="true"] .spt-card { opacity: 1; transition: opacity ${FADE_MS}ms ${FOCUS_EASE} ${TEXT_OUT_MS}ms; }
.spt[data-closing="true"] .spt-card[data-hot="true"] { visibility: hidden; transition: none; width: var(--spt-s); height: var(--spt-s); transform: translate(-50%, -50%); }
/* Story open: every picture fades away; the one that opened hides at once, its copy glides. */
.spt[data-open="true"] .spt-card { opacity: 0 !important; pointer-events: none; transition-duration: ${FADE_MS}ms; }
.spt[data-open="true"] .spt-card[data-hot="true"] { transition: none; visibility: hidden; }
.spt-story { position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: auto minmax(0, 27rem);
  align-items: center; justify-content: center; gap: clamp(20px, 4vw, 36px); visibility: hidden; pointer-events: none; }
.spt[data-stack="true"] .spt-story { grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 18px; }
.spt[data-open="true"] .spt-story, .spt[data-closing="true"] .spt-story { visibility: visible; pointer-events: auto; }
.spt-pic { position: relative; display: block; width: var(--spt-big); height: var(--spt-big); margin: 0; padding: 0; border: 0; overflow: hidden;
  border-radius: var(--spt-r); background: color-mix(in oklab, var(--spt-fg) 8%, var(--spt-bg)); cursor: pointer; outline: none; transform-origin: 0 0; }
.spt-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; user-select: none; }
.spt-pic:focus-visible { box-shadow: 0 0 0 2px var(--spt-bg), 0 0 0 4px color-mix(in oklab, var(--spt-fg) 55%, transparent); }
.spt-text { min-width: 0; padding-right: 28px; }
.spt[data-stack="true"] .spt-text { padding-right: 0; }
.spt[data-stack="true"] .spt-title { font-size: 22px; }
/* The story drops in from above, line by line, coming into focus as it lands. */
.spt-line { opacity: 0; transform: translateY(-${TEXT_DROP}px); filter: blur(${TEXT_BLUR}px); }
.spt[data-shown="true"] .spt-line { opacity: 1; transform: none; filter: none;
  transition: opacity ${TEXT_MS}ms ${FOCUS_EASE}, transform ${TEXT_MS}ms ${FOCUS_EASE}, filter ${TEXT_MS}ms ${FOCUS_EASE};
  transition-delay: calc(${TEXT_DELAY}ms + var(--i) * ${TEXT_STAGGER}ms); }
.spt[data-closing="true"] .spt-line { opacity: 0; transform: translateY(-${TEXT_DROP / 2}px); filter: none;
  transition: opacity ${TEXT_OUT_MS}ms ease, transform ${TEXT_OUT_MS}ms ease; }
.spt-title { margin: 0 0 12px; font-size: 26px; font-weight: 500; line-height: 1.2; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.spt-points { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.spt-points li { position: relative; padding-left: 18px; font-size: 15px; line-height: 1.5; color: color-mix(in oklab, var(--spt-fg) 72%, transparent); overflow-wrap: anywhere; }
.spt-points li::before { content: ""; position: absolute; left: 3px; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: color-mix(in oklab, var(--spt-fg) 45%, transparent); }
.spt-cta { display: inline-flex; align-items: center; height: 36px; margin-top: 18px; padding: 0 16px; border-radius: 999px; font: inherit; font-size: 14px; font-weight: 500;
  color: var(--spt-fg); text-decoration: none; cursor: pointer; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in oklab, var(--spt-fg) 6%, var(--spt-bg)); border: 1px solid color-mix(in oklab, var(--spt-fg) 14%, transparent);
  transition: background-color 150ms ease, transform 150ms ease; outline: none; -webkit-tap-highlight-color: transparent; }
.spt-cta:active { transform: scale(.97); }
.spt-cta:focus-visible, .spt-close:focus-visible { box-shadow: 0 0 0 2px var(--spt-bg), 0 0 0 4px color-mix(in oklab, var(--spt-fg) 55%, transparent); }
.spt-close { position: absolute; top: 0; right: 0; z-index: 3; display: grid; place-items: center; width: 32px; height: 32px; margin: 0; padding: 0; border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--spt-fg) 12%, transparent); background: color-mix(in oklab, var(--spt-fg) 4%, var(--spt-bg)); color: var(--spt-fg);
  cursor: pointer; outline: none; transition: background-color 150ms ease; -webkit-tap-highlight-color: transparent; }
.spt[data-stack="true"] .spt-close { top: 8px; right: 8px; }
@media (hover: hover) {
  .spt-cta:hover { background: color-mix(in oklab, var(--spt-fg) 11%, var(--spt-bg)); }
  .spt-close:hover { background: color-mix(in oklab, var(--spt-fg) 10%, var(--spt-bg)); }
}
@media (prefers-reduced-motion: reduce) {
  .spt, .spt-card, .spt-line { transition-property: opacity !important; }
  .spt-line { transform: none !important; filter: none !important; }
}`;

type Hot = { key: string; index: number; el: HTMLElement };

/** A picture that fails to load hides, so the soft square behind it shows instead of a broken icon. */
const hideBroken = (e: { currentTarget: HTMLImageElement }) => {
  e.currentTarget.style.visibility = "hidden";
};
/** The same check for a picture that failed before the page came alive (its error event is already gone). */
const checkBroken = (img: HTMLImageElement | null) => {
  if (img?.complete && !img.naturalWidth) img.style.visibility = "hidden";
};

const clamp = (v: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, v));

export function SpotlightTicker({
  items,
  direction = "left",
  speed = 32,
  size = 160,
  radius = 16,
  className,
  style,
  "aria-label": ariaLabel = "Pictures",
}: SpotlightTickerProps) {
  const root = useRef<HTMLDivElement>(null);
  const view = useRef<HTMLDivElement>(null);
  const track = useRef<HTMLDivElement>(null);
  const story = useRef<HTMLDivElement>(null);
  const pic = useRef<HTMLButtonElement>(null);
  const closeBtn = useRef<HTMLButtonElement>(null);

  const [width, setWidth] = useState(0);
  const [canHover, setCanHover] = useState(false);
  const [still, setStill] = useState(false); // reduced motion: no auto scroll
  const [phone, setPhone] = useState(false); // a small screen: smaller pictures
  const [hot, setHot] = useState<Hot | null>(null);
  const [open, setOpen] = useState<number | null>(null); // index of the open story
  const [closing, setClosing] = useState(false);
  const [linesIn, setLinesIn] = useState(false); // the story's lines, a frame after it mounts, so they can drop in
  const [height, setHeight] = useState<number | null>(null);

  const n = items.length;
  // Smaller screens shrink the pictures, so a few always show.
  const s = width ? Math.round(clamp(Math.min(phone ? size * SMALL : size, width * 0.36), 56, size)) : size;
  const gap = Math.round(s * GAP);
  const step = s + gap;
  const setW = n * step;
  const restH = Math.ceil(canHover ? s * ZOOM + SHADOW_ROOM * 2 : s + 24); // room for the grown picture and its shadow
  const fade = Math.round(Math.min(s * EDGE, width * 0.08));
  const stack = width > 0 && width < STACK_AT;
  const big = Math.round(stack ? Math.min(width, s * ZOOM) : s * ZOOM);
  const copies = still || !setW ? 1 : Math.max(2, Math.ceil(width / setW) + 1);

  // Motion state lives in refs so the row moves without re-rendering.
  const offset = useRef(0);
  const velocity = useRef(0);
  const paused = useRef(false);
  const visible = useRef(true);
  const openedAt = useRef(0); // when the story opened, so the click that opened it doesn't close it

  /* Watch the width, hover support and reduced motion. */
  useLayoutEffect(() => {
    const el = root.current;
    if (!el) return;
    const ro = new ResizeObserver(() => setWidth(el.clientWidth));
    ro.observe(el);
    setWidth(el.clientWidth);
    const hoverQ = window.matchMedia("(hover: hover) and (pointer: fine)");
    const motionQ = window.matchMedia("(prefers-reduced-motion: reduce)");
    const phoneQ = window.matchMedia(`(max-width: ${SMALL_AT - 0.02}px)`);
    const qs = [hoverQ, motionQ, phoneQ];
    const sync = () => {
      setCanHover(hoverQ.matches);
      setStill(motionQ.matches);
      setPhone(phoneQ.matches);
    };
    sync();
    qs.forEach((q) => q.addEventListener("change", sync));
    return () => {
      ro.disconnect();
      qs.forEach((q) => q.removeEventListener("change", sync));
    };
  }, []);

  /* The ticker: eases toward full speed, or toward a stop while something is in focus. */
  useEffect(() => {
    if (still || !setW) return;
    const dir = direction === "right" ? -1 : 1;
    let raf = 0;
    let last = performance.now();
    const io = new IntersectionObserver(([e]) => (visible.current = e.isIntersecting));
    if (root.current) io.observe(root.current);
    const tick = (now: number) => {
      const dt = Math.min(0.05, (now - last) / 1000);
      last = now;
      const target = paused.current ? 0 : Math.max(0, speed || 0);
      const ease = target < velocity.current ? STOP_MS : START_MS;
      velocity.current += (target - velocity.current) * Math.min(1, (dt * 1000 * 3) / ease);
      if (Math.abs(target - velocity.current) < 0.6) velocity.current = target; // a clean stop, no endless creep
      if (visible.current && !document.hidden) {
        offset.current = (((offset.current + velocity.current * dt * dir) % setW) + setW) % setW;
        if (track.current) track.current.style.transform = `translate3d(${-offset.current}px,0,0)`;
      }
      raf = requestAnimationFrame(tick);
    };
    raf = requestAnimationFrame(tick);
    return () => {
      cancelAnimationFrame(raf);
      io.disconnect();
    };
  }, [still, setW, speed, direction]);

  paused.current = hot !== null || open !== null || closing;

  /* Where a picture sits in the view right now, in px from the view's left edge. */
  const leftInView = useCallback(
    (el: HTMLElement) => {
      const v = view.current!.getBoundingClientRect();
      const slot = (el.parentElement as HTMLElement).getBoundingClientRect();
      return slot.left - v.left + (slot.width - s) / 2;
    },
    [s],
  );

  /* Bring a picture into focus: it grows, steps inward if it would spill off an edge. */
  const placeGrown = useCallback(
    (el: HTMLElement) => {
      const vw = view.current?.clientWidth ?? 0;
      const zw = s * ZOOM;
      const want = leftInView(el) + s / 2 - zw / 2;
      // Keep it clear of the faded edges too.
      const f = Math.round(Math.min(s * EDGE, vw * 0.08));
      el.style.setProperty("--spt-dx", `${Math.round(clamp(want, f, Math.max(f, vw - zw - f)) - want)}px`);
    },
    [s, leftInView],
  );

  const focusOn = useCallback(
    (el: HTMLElement, key: string, index: number) => {
      if (open !== null || closing) return;
      placeGrown(el);
      setHot({ key, index, el });
    },
    [open, closing, placeGrown],
  );

  /* The row drifts a few px while it slows down: place the grown picture again once it has stopped. */
  useEffect(() => {
    if (!hot || open !== null || closing) return;
    const t = setTimeout(() => placeGrown(hot.el), STOP_MS * 2);
    return () => clearTimeout(t);
  }, [hot, open, closing, placeGrown]);

  const blur = useCallback(() => {
    if (open === null && !closing) setHot(null);
  }, [open, closing]);

  /* Open a story: the others fade, the picture glides from where it is to its place beside the story. */
  const openStory = useCallback(
    (el: HTMLElement, key: string, index: number) => {
      if (open !== null || closing) return;
      const from = el.getBoundingClientRect();
      openedAt.current = performance.now();
      setHot({ key, index, el });
      setOpen(index);
      requestAnimationFrame(() => {
        const p = pic.current;
        if (!p) return;
        const to = p.getBoundingClientRect();
        const k = from.width / to.width;
        p.animate(
          [
            { transform: `translate(${from.left - to.left}px, ${from.top - to.top}px) scale(${k})`, borderRadius: `${radius / k}px` },
            { transform: "none", borderRadius: `${radius}px` },
          ],
          { duration: still ? 0 : GLIDE_MS, easing: GLIDE_EASE },
        );
        closeBtn.current?.focus({ preventScroll: true });
        // Wait one more frame so the lines are drawn hidden first; then they drop in.
        requestAnimationFrame(() => setLinesIn(true));
      });
    },
    [open, closing, radius, still],
  );

  /* Close it: the story leaves, the picture glides back to its place in the row, the others return. */
  const closeStory = useCallback(() => {
    if (open === null || closing || !hot) return;
    const p = pic.current;
    const el = hot.el;
    setClosing(true);
    setOpen(null);
    setLinesIn(false);
    const done = () => {
      returnTo.current = hot;
      setClosing(false);
      setHot(null);
    };
    if (!p || still) return done();
    // Closed mid-glide: start from where the picture is right now.
    const now = p.getBoundingClientRect();
    p.getAnimations().forEach((a) => a.cancel());
    const to = p.getBoundingClientRect();
    const k0 = now.width / to.width;
    const slot = (el.parentElement as HTMLElement).getBoundingClientRect();
    const fx = slot.left + (slot.width - s) / 2;
    const fy = slot.top + (slot.height - s) / 2;
    const k = s / to.width;
    const anim = p.animate(
      [
        { transform: `translate(${now.left - to.left}px, ${now.top - to.top}px) scale(${k0})`, borderRadius: `${radius / k0}px` },
        { transform: `translate(${fx - to.left}px, ${fy - to.top}px) scale(${k})`, borderRadius: `${radius / k}px` },
      ],
      { duration: CLOSE_MS, delay: TEXT_OUT_MS / 2, easing: GLIDE_EASE, fill: "forwards" },
    );
    anim.onfinish = () => {
      done();
      // Let the row paint first, then drop the held frame.
      requestAnimationFrame(() => anim.cancel());
    };
  }, [open, closing, hot, still, s, radius]);

  /* Once the picture shows in the row again: focus goes back to it, and if the mouse is still on it, it grows again. */
  const returnTo = useRef<Hot | null>(null);
  useEffect(() => {
    const back = returnTo.current;
    if (closing || open !== null || !back) return;
    returnTo.current = null;
    back.el.focus({ preventScroll: true });
    if (canHover && back.el.matches(":hover")) focusOn(back.el, back.key, back.index);
  }, [closing, open, canHover, focusOn]);

  /* Like a pop up: Esc or a click anywhere outside the story closes it. */
  useEffect(() => {
    if (open === null) return;
    const onKey = (e: KeyboardEvent) => e.key === "Escape" && closeStory();
    // A click, not a touch: a finger scrolling the page past it leaves it open.
    const onClick = (e: MouseEvent) => {
      if (e.timeStamp <= openedAt.current) return;
      const t = e.target as Element | null;
      if (!t?.closest?.(".spt-pic, .spt-text, .spt-close") || !root.current?.contains(t)) closeStory();
    };
    window.addEventListener("keydown", onKey);
    document.addEventListener("click", onClick, true);
    return () => {
      window.removeEventListener("keydown", onKey);
      document.removeEventListener("click", onClick, true);
    };
  }, [open, closeStory]);

  /* The block grows to fit a tall story, then shrinks back. */
  useLayoutEffect(() => {
    if (open === null) return setHeight(null);
    const el = story.current;
    if (!el) return;
    const fit = () => setHeight(Math.max(restH, el.offsetHeight));
    fit();
    const ro = new ResizeObserver(fit);
    ro.observe(el);
    return () => ro.disconnect();
  }, [open, restH]);

  /* Keyboard: a focused picture comes into view (the view never scrolls on its own). */
  const onCardFocus = (el: HTMLElement, key: string, index: number) => {
    const v = view.current;
    if (!v) return;
    if (!still) {
      v.scrollLeft = 0;
      const vw = v.clientWidth;
      const x = leftInView(el);
      if (x < 0 || x + s > vw) {
        offset.current = (((offset.current + x - (vw - s) / 2) % setW) + setW) % setW;
        if (track.current) track.current.style.transform = `translate3d(${-offset.current}px,0,0)`;
      }
    }
    if (el.matches(":focus-visible")) focusOn(el, key, index);
  };

  const shown = open ?? (closing ? hot?.index ?? null : null);
  const item = shown !== null ? items[shown] : null;

  if (!n) return null;

  return (
    <div
      ref={root}
      className={["spt", className].filter(Boolean).join(" ")}
      role="region"
      aria-roledescription="ticker"
      aria-label={ariaLabel}
      data-hot={hot !== null || undefined}
      data-open={open !== null || undefined}
      data-shown={linesIn || undefined}
      data-closing={closing || undefined}
      data-stack={stack || undefined}
      data-still={still || undefined}
      style={
        {
          "--spt-s": `${s}px`,
          "--spt-r": `${radius}px`,
          "--spt-big": `${big}px`,
          "--spt-h": `${restH}px`,
          "--spt-fade": `${fade}px`,
          height: height ?? restH,
          ...style,
        } as CSSProperties
      }
      onPointerLeave={blur}
    >
      <style>{CSS}</style>
      <div ref={view} className="spt-view" onScroll={(e) => !still && (e.currentTarget.scrollLeft = 0)}>
        <div ref={track} className="spt-track" style={{ width: setW * copies }}>
          {Array.from({ length: copies }, (_, c) =>
            items.map((it, i) => {
              const key = `${c}-${i}`;
              const copy = c > 0;
              return (
                <div key={key} className="spt-slot" style={{ width: step }}>
                  <button
                    type="button"
                    className="spt-card"
                    data-hot={hot?.key === key || undefined}
                    aria-hidden={copy || undefined}
                    tabIndex={copy || open !== null ? -1 : 0}
                    aria-label={`${it.title}: open`}
                    onPointerEnter={(e) => e.pointerType === "mouse" && focusOn(e.currentTarget, key, i)}
                    onPointerLeave={(e) => e.pointerType === "mouse" && hot?.key === key && blur()}
                    onFocus={(e) => onCardFocus(e.currentTarget, key, i)}
                    onBlur={() => hot?.key === key && open === null && blur()}
                    onClick={(e) => openStory(e.currentTarget, key, i)}
                  >
                    <img src={it.image.src} alt={copy ? "" : it.image.alt} loading="lazy" decoding="async" draggable={false} onError={hideBroken} ref={checkBroken} />
                  </button>
                </div>
              );
            }),
          )}
        </div>
      </div>

      <div ref={story} className="spt-story" aria-hidden={open === null} style={{ minHeight: restH }}>
        {item && (
          <>
            <button ref={closeBtn} type="button" className="spt-close spt-line" style={{ "--i": 0 } as CSSProperties} aria-label="Close" onClick={closeStory}>
              <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
                <path d="M18.9991 19L5 5.00098" />
                <path d="M19 5L5.00092 18.999" />
              </svg>
            </button>
            <button
              ref={pic}
              type="button"
              className="spt-pic"
              tabIndex={-1}
              aria-label="Close"
              onClick={closeStory}
            >
              <img src={item.image.src} alt={item.image.alt} draggable={false} onError={hideBroken} ref={checkBroken} />
            </button>
            <div className="spt-text">
              <h3 className="spt-title spt-line" style={{ "--i": 0 } as CSSProperties}>
                {item.title}
              </h3>
              <ul className="spt-points">
                {item.points.map((p, j) => (
                  <li key={j} className="spt-line" style={{ "--i": j + 1 } as CSSProperties}>
                    {p}
                  </li>
                ))}
              </ul>
              {item.cta && (
                <div className="spt-line" style={{ "--i": item.points.length + 1 } as CSSProperties}>
                  {item.cta.href ? (
                    <a
                      className="spt-cta"
                      href={item.cta.href}
                      target={item.cta.target}
                      rel={item.cta.target === "_blank" ? "noopener noreferrer" : undefined}
                      onClick={item.cta.onClick}
                    >
                      {item.cta.label}
                    </a>
                  ) : (
                    <button type="button" className="spt-cta" onClick={item.cta.onClick}>
                      {item.cta.label}
                    </button>
                  )}
                </div>
              )}
            </div>
          </>
        )}
      </div>
    </div>
  );
}

export default SpotlightTicker;
```

Usage

Give each picture a heading, two to four short bullet points and one button. Give the ticker the full width of its section.

import { SpotlightTicker } from "@/components/ui/spotlight-ticker";

const ITEMS = [
  {
    image: { src: "/showcase/comet-button.webp", alt: "Comet button, a glow racing round its border" },
    title: "Comet button",
    points: [
      "A glow races round the border while it loads.",
      "Success lights the whole border, then eases back.",
    ],
    cta: { label: "Open component", href: "/docs/comet-button" },
  },
  // one entry per picture, 5 to 10 reads best
];

export function Showcase() {
  return <SpotlightTicker items={ITEMS} aria-label="Our components" />;
}

Keep each picture small (about 500px square, WebP). Pictures load only when they come near the screen.

How it moves

A row that stops for the picture you point at, and opens it like a pop up.

The row glides at a calm 32 pixels a second, slow enough to see every picture. Point at one and the row slows to a stop as the picture slowly grows to 1.8 times its size, and the others dim to 40%, so the one you chose is in focus. Both sides of the row fade out softly, so no picture is ever cut off with a hard edge, and near an edge the grown picture steps inward.

Click it and the others fade away while the picture glides to the left. The heading, each bullet point and the button drop in from above, line by line. Close it with the X, Esc, a click on the picture or a click anywhere outside: the picture glides home in under a second, the others come back and the row carries on. Phones have no hover, so one tap opens the story, with smaller pictures and the story under the picture. With reduced motion the row stands still and scrolls by hand.

Props

PropDefaultWhat it does
items—The pictures, in order. Each one: image { src, alt }, title, points (the bullet points) and cta { label, href or onClick, target }.
direction"left"Which way the row moves: "left" or "right".
speed32How fast the row moves, in pixels per second, like most marquees. 32 lets people see each picture; 50 is brisk, 80 is fast.
size160Side of each picture at rest, in px. It grows to 1.8 times this in focus. Phones show it at 70%.
radius16Corner radius of the pictures in px, at rest, in focus and in the story.
aria-label"Pictures"What screen readers call the row.
className / style—On the outer block. It fills its width and is 1.8 times size plus 96px tall, room for the grown picture and its shadow.