Installation
Usage
"use client"
import * as React from "react"
import { ProductTour } from "@/components/product-tour"
export function Welcome() {
const [open, setOpen] = React.useState(false)
return (
<div>
<button type="button" data-tour="new" onClick={() => setOpen(true)}>
Take the tour
</button>
<ProductTour
open={open}
onOpenChange={setOpen}
steps={[
{ target: "[data-tour='new']", title: "Start here", body: "Create your first report." },
{ title: "That's it", body: "You can replay this tour from Help." },
]}
/>
</div>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| steps | TourStep[] | — | Each step: target (a CSS selector or a function), title and body. No target centres the card. |
| open | boolean | — | Whether the tour is running. Leave it out to let the tour run itself. |
| defaultOpen | boolean | false | Run the tour once the page has loaded, when open is left out. |
| onOpenChange | (open, finished) => void | — | Called with false when it ends; finished tells a completed tour from a skipped one. |
| padding | number | 6 | Space around the highlighted element, in pixels. |
| radius | number | 12 | Rounded corners of the highlight, in pixels. |
| nextLabel / backLabel / skipLabel / doneLabel | string | Next / Back / Skip / Done | Button text. |
Accessibility
- A modal dialog: focus moves into the card, Tab stays inside, Escape skips, and Left and Right step through.
- Focus returns to where it was when the tour ends.
- The highlighted element scrolls into view; the card stays on screen at every size.
- The spotlight jumps instead of gliding under prefers-reduced-motion.
Changelog
- v1.1.0Latest
open and onOpenChange are now optional: give it defaultOpen and the tour runs by itself once the page has loaded, e.g. on a first visit.
- v1.0.0
First release.