# Spotlight Tour

> A product tour whose scrim cutout springs between targets, morphing size and concentric radius while the tooltip re-anchors.

Also known as a product tour.

- Tier: Eased Pro
- Interaction: Slide
- Page: https://eased.dev/components/spotlight-tour
- Installs: motion

## Install

Spotlight Tour ships with Eased Pro (https://eased.dev/#pricing). Members add the `@eased-pro` registry with their token (https://eased.dev/account), then run:

```bash
npx shadcn add @eased-pro/spotlight-tour
```

A step-by-step product tour: a dimmed, blurred scrim with a rounded cutout that springs from target to target, and one tooltip dialog that travels beside it.

## When to use

- A first-run walkthrough of three to six controls on a screen people have not seen before.
- Pointing at real UI in place, where a static screenshot or a docs page would lose the context.
- A tour someone can start again later from a "Take the tour" button, with Back and Skip.

## When not to use

- One hint on one control: use a [Popover](/components/popover) or a [Tooltip](/components/tooltip).
- Setup the person has to complete, with progress that persists: use an [Onboarding Checklist](/components/onboarding-checklist).
- Anything the person must act on inside the highlighted element: the page behind the tour is inert by default, so the target can be seen but not used.

## Usage

```tsx example.tsx
import { useRef, useState } from "react";
import { SpotlightTour, type SpotlightStep } from "@/components/eased/spotlight-tour/spotlight-tour";

export function Example() {
  const [open, setOpen] = useState(false);
  const navRef = useRef<HTMLElement>(null);
  const createRef = useRef<HTMLButtonElement>(null);

  const steps: SpotlightStep[] = [
    {
      target: navRef,
      placement: "right",
      title: "Everything lives here",
      body: "Jump between projects, analytics and your team from the sidebar.",
    },
    {
      target: createRef,
      placement: "bottom-end",
      title: "Start a project",
      body: "Start from a template or a blank canvas in a few clicks.",
    },
  ];

  return (
    <>
      <nav ref={navRef} aria-label="Main">…</nav>
      <button ref={createRef} type="button">New project</button>
      <button type="button" onClick={() => setOpen(true)}>Take the tour</button>
      <SpotlightTour steps={steps} open={open} onClose={() => setOpen(false)} />
    </>
  );
}
```

Keep the tour mounted and toggle `open`, so closing plays the exit.

## Examples

### Contained in a panel

`contained` covers the nearest positioned ancestor instead of the viewport and renders in place (no portal). String targets are then looked up inside that ancestor, and scrolling into view is off by default.

```tsx
<div className="relative h-96 overflow-hidden">
  <Dashboard />
  <SpotlightTour contained steps={steps} open={open} onClose={() => setOpen(false)} />
</div>
```

### Controlled step

Pass `step` with `onStepChange` to open on a particular step, for example from a button next to the feature it explains. `onStepChange` also fires once with the opening step.

```tsx
const [step, setStep] = useState(0);

<SpotlightTour
  steps={steps}
  open={open}
  step={step}
  onStepChange={setStep}
  onClose={(reason) => {
    setOpen(false);
    if (reason === "done") markTourSeen();
  }}
/>
```

### Selector and lazy targets

A target can be a ref, a CSS selector, or a function that returns the element. Targets are resolved on every step change and resize, so a function suits elements that mount late. A step whose target is missing centres the tooltip with no cutout.

```tsx
const steps: SpotlightStep[] = [
  { target: "#search", title: "Find anything fast", body: "Search projects, people and docs." },
  { target: () => document.querySelector<HTMLElement>("[data-tour='billing']"), title: "Billing", body: "Invoices and plan changes live here." },
];
```

## API reference

### SpotlightTour

| Prop | Type | Default | Description |
|---|---|---|---|
| `steps` | `SpotlightStep[]` | | The steps in order. Nothing renders while it is empty. |
| `open` | `boolean` | | Shows the tour. Keep the component mounted and toggle this so the exit animates. |
| `onClose` | `(reason: "done" \| "skip") => void` | | `"done"` from Done on the last step; `"skip"` from Skip, `Escape` or a scrim click. |
| `onStepChange` | `(index: number) => void` | | Called with the first step when the tour opens, then with every step Next, Back or the arrow keys ask for. |
| `step` | `number` | | The current step, controlled. Clamped to the steps' range. |
| `defaultStep` | `number` | `0` | The step the tour opens on when uncontrolled. |
| `contained` | `boolean` | `false` | Cover the nearest positioned ancestor instead of the viewport, rendered in place instead of portalled to `<body>`. |
| `padding` | `number` | `6` | Gap between the target and the cutout edge, in px. |
| `closeOnScrimClick` | `boolean` | `false` | Clicking the scrim skips the tour. Off so a stray click does not end it. |
| `scrollIntoView` | `false \| ScrollIntoViewOptions` | `{ block: "nearest", inline: "nearest" }` | How each step brings its target into view, or `false` to leave scrolling alone. `false` when `contained`. |
| `inertOutside` | `boolean` | `true` | Makes the tour layer's siblings `inert` while it is open: the rest of the page, or the container's other children when `contained`. |
| `renderStep` | `(step: SpotlightStep, index: number) => ReactNode` | | Renders a step's body in place of `body`, e.g. links or an image. Focusable content joins the focus trap. |
| `labels` | `Partial<SpotlightLabels>` | | Button text and the progress announcement. |

### SpotlightStep

| Field | Type | Default | Description |
|---|---|---|---|
| `target` | `RefObject<HTMLElement \| null> \| string \| (() => HTMLElement \| null)` | | The element to highlight. A selector is scoped to the container when `contained`. |
| `title` | `ReactNode` | | The dialog's name for this step. |
| `body` | `ReactNode` | | The dialog's description for this step. |
| `placement` | `SpotlightPlacement` | | `"top"`, `"bottom"`, `"left"` or `"right"`, optionally `-start` or `-end` to align to that edge of the cutout. Left out, the tooltip stays on its current side when it fits, else takes the fitting side it has the least distance to travel to. A side that does not fit falls back the same way. |
| `padding` | `number` | | Overrides the tour's `padding` for this step. |
| `radius` | `number` | | The cutout's corner radius in px. Default: the target's own top-left radius plus the padding, so the cutout is concentric. |

### SpotlightLabels

| Field | Type | Default | Description |
|---|---|---|---|
| `skip` | `string` | `"Skip"` | Hidden on the last step. |
| `back` | `string` | `"Back"` | Hidden on the first step. |
| `next` | `string` | `"Next"` | |
| `done` | `string` | `"Done"` | Next's label on the last step. |
| `progress` | `(step: number, total: number) => string` | | Announced before each step's title; `step` counts from 1. Default: "Step 2 of 4". |

The tooltip is 248px wide and never sits closer than 8px to the layer's edge. It stays glued to its target through scrolling and resizing.

## Keyboard

| Key | Action |
|---|---|
| `→` | Next step. Does nothing on the last step: Done takes a click or `Enter`. |
| `←` | Previous step. |
| `Escape` | Skips the tour (`onClose("skip")`). |
| `Tab` / `Shift+Tab` | Cycles through the tooltip's buttons and any focusable content from `renderStep`. |
| `Enter` / `Space` | Activates the focused button. |

The arrow keys are ignored while focus is in an input, textarea, select or editable element.

## Accessibility

- The tooltip is a `role="dialog"` with `aria-modal`, named by the current step's title (`aria-labelledby`) and described by its body (`aria-describedby`).
- Every step's title and body are stacked in the same place; the ones not showing are `aria-hidden` and `inert`, so only the current step is read or reachable.
- A polite live region reads the progress and title on each step, the first one included (it mounts empty and fills a frame later), e.g. "Step 2 of 4: Find anything fast". The visual "2/4" counter is `aria-hidden`.
- `inertOutside` keeps assistive tech and focus inside the dialog, since `aria-modal` alone does not stop a screen reader reading what is behind the scrim. Turn it off only if you manage that yourself.
- Focus moves to Next (then Done) on open and is trapped in the tooltip. When Back disappears on the first step or Skip on the last, focus moves to Next rather than falling to `<body>`. Closing hands focus back to whatever was focused when the tour opened, without waiting for the exit.
- The scrim and highlight ring are `aria-hidden`. The buttons have extended hit areas.

## Motion

The cutout and the tooltip share one spring: `smooth` stretched to a 0.45s visual duration, with no overshoot, so they leave and arrive together. The cutout's centre, size and corner radius all ride it, and its width and height spring in log space so a move from a tall target to a wide one does not bulge in the middle. On open the cutout starts 24px wider on every side and closes onto the first target, while the tooltip grows out of the target's edge: from 6px toward it and scale 0.97 on `snappy`, fading in over 200ms. Each step change springs the tooltip straight from where it is to its new place; its title and body swap (out up 3px, in from 4px below, 4px blur, `snappy` with 150ms fades), the step counter rolls in the direction of travel, Next turns into Done in place, and Skip and Back fade and scale in or out (out in 100ms). Scrolling or resizing keeps everything glued without animating, and retargets the springs if a move is in flight. The whole layer fades in over 200ms and out over 150ms. Reduced motion: the cutout and tooltip jump, the tooltip fades in over 100ms, swaps are opacity only and scrolling into view is instant.

## Notes for AI

Pick Spotlight Tour for a short guided walkthrough of existing controls. Give each step a ref target, a short title and a one or two sentence body, and set `placement` where the layout calls for a side. Use `contained` when the tour belongs to a panel or preview, and `step` with `onStepChange` when another control should open it on a specific step. Persist "seen" yourself from `onClose("done")`.

Do not render it conditionally (`{open && <SpotlightTour />}`), which skips the exit; toggle `open` instead. Do not add your own scrim, focus trap, `inert` handling, scroll-into-view or arrow-key handling: all of them are built in. Do not expect people to click the highlighted target while `inertOutside` is on.

## Related

- [Onboarding Checklist](/components/onboarding-checklist): setup tasks that persist, instead of a guided look around.
- [Popover](/components/popover): one anchored hint the person opens themselves.
- [Tooltip](/components/tooltip): a short label on hover or focus.
