# First run tour

Spotlight coachmarks that point at the real interface, with a cut out that glides from target to target and a tour that resumes where it was left.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: First run tour. A first visit: the cut out glides from the composer to files, the model picker and projects, then a closing step. Preview: https://chatcn.dev/preview/first-run-tour-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/first-run-tour
```

## Usage

```tsx
import { FirstRunTour } from "@/components/ui/chatcn/pro/first-run-tour"

<FirstRunTour
  steps={[
    { target: "composer", title: "Ask anything here", body: "Enter sends." },
    { target: "model", title: "Pick the model" },
    { title: "That is everything" },
  ]}
  defaultOpen={isFirstVisit}
  storageKey="tour:v1"
>
  <App />
</FirstRunTour>
```

Wrap the app and mark targets with `data-tour`. The app dims except for a cut out around the current target, and the cut out glides to the next one rather than jumping, so the eye follows. The card sits below the target when it fits, otherwise above, and a step with no target sits in the middle. Arrow keys move through it, Escape leaves, and with `storageKey` a tour left halfway resumes at the same step next time. While it is open the app behind is inert, so nothing gets clicked by accident.

## Examples

### States

Example: States. A step with the card above the target, one with the card below, and a centered closing step. Preview: https://chatcn.dev/preview/first-run-tour-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `children` | `ReactNode` | The app, with `data-tour` targets |
| `steps` | `TourStep[]` | `{ target?, title, body? }` |
| `open`, `defaultOpen`, `onOpenChange` | `boolean` |  |
| `step`, `defaultStep`, `onStepChange` | `number` |  |
| `onFinish`, `onSkip` | `() => void`, `(step) => void` | Done, or left at a step |
| `storageKey` | `string | null` | Remember the step to resume |
| `labels` | `Partial<FirstRunTourLabels>` | Every string, for translation |

## Keyboard

| Key | Action |
| --- | --- |
| Right, Left | Next, back (reversed right to left) |
| Escape | Leave the tour |
| Tab | Move between the card's buttons |

## Accessibility

- The card is a modal dialog named by the step's title, focused on each step.
- The app behind is inert while the tour is open.
- The step count is text, beside a progress line.

## Motion

The cut out and the card glide to the next target in 360 ms on the kit's ease out. Under reduced motion they move at once.

Source: https://chatcn.dev/docs/components/first-run-tour