Pro (paid add-on)
Product tour
ProTour walks people through your interface: each step highlights an element, dims the rest of the page and explains it in a card beside it, as an accessible modal dialog.
Part of Pro
This page documents part of @vjdesigns-pro/ui, the paid add-on package. Using it needs a Pro license and @vjdesigns/vjdesigns-ui 3.8.0 or later. Like the free package, it works in both modes, every brand, all 32 languages and right to left. Install it as described in Account forms.
Example
Each step highlights an element (a ref, a CSS selector, or a function that finds it), dims the rest of the page, and explains it in a card beside it with Back, Continue or Finish, and "Step 2 of 4". Leave out target for a centered step, such as a welcome. A target that isn't on the page falls back to centered too.
import { Tour } from "@vjdesigns-pro/ui";
import { Button } from "@vjdesigns/vjdesigns-ui";
const [open, setOpen] = useState(false);
<Button onClick={() => setOpen(true)}>Take the tour</Button>
<Tour
open={open}
onOpenChange={setOpen}
onComplete={markTourSeen}
steps={[
{ title: "Welcome to Courtside", content: <p>Take a quick look around.</p> },
{ target: "#search", title: "Search anything", content: <p>Find players, games, and teams.</p> },
{ target: newGameRef, title: "Schedule a game", placement: "bottom-end", content: <p>Players get notified.</p> },
]}
/>
Accessible by default
- Each step is a modal dialog named by its title and described by its content. Focus moves to the title on every step, so screen readers read it.
- Tab stays in the card, and the rest of the page is inert while the tour is open.
- Escape or Close ends the tour, and focus returns to where it was.
- The target scrolls into view (without animating under reduced motion), and the spotlight follows it through scrolling and resizing.
- In Windows High Contrast mode, the target gets a system-color outline instead of the dimming.
Control and options
openandonOpenChangeshow and hide the tour;stepandonStepChangecontrol the current step.onCompleteruns only when Finish is pressed, so you can remember that someone finished the tour.placementon a step sets where its card sits (for example"bottom-end").spotlight={false}turns off the dimming, andlabelsoverrides the button text and the progress format.
Props
Tour
A guided walkthrough of your interface: each step highlights an element and explains it in a card beside it, with Back, Next, and Finish.
Accessibility: each step is a modal dialog (role="dialog", aria-modal="true") named by its title and described by its content. Focus moves to the step's title when the tour opens and on every step, so screen readers read it; Tab stays inside the card; the rest of the page is inert while the tour is open (the highlight is visual only). Escape or the close button ends the tour, and focus returns to where it was. Progress ("Step 2 of 4") is text, never only dots or color.
| Prop | Type | Default |
|---|---|---|
stepsRequiredThe stops, in order. | TourStep[] | — |
openControlled open state. | boolean | — |
defaultOpenInitial open state when uncontrolled. | boolean | false |
onOpenChangeCalled with | (open: boolean) => void | — |
stepControlled current step (0-based). | number | — |
defaultStepInitial step when uncontrolled (0-based). | number | 0 |
onStepChangeCalled with the new step index when the user goes Back or Next. | (step: number) => void | — |
onCompleteCalled when the user presses Finish on the last step (before the tour closes). | () => void | — |
spotlightDim the page around the target. | boolean | true |
spotlightPaddingSpace between the target and the spotlight's edge, in px. | number | 8 |
labelsText overrides for the buttons and progress. | TourLabels | — |
classNameAdditional class for the step card. | string | — |
TourStep
One stop on the tour.
| Prop | Type | Default |
|---|---|---|
targetThe element to highlight and point at. Leave it out (or let it resolve to nothing) for a step centered on the screen, such as a welcome. | TourTarget | — |
titleRequiredHeading of the step; the dialog's accessible name. | ReactNode | — |
contentWhat to know about the target; the dialog's accessible description. | ReactNode | — |
placementPreferred side of the target for the card. Flips when there isn't room. | "top""top-start""top-end""bottom""bottom-start""bottom-end""left""left-start""left-end""right""right-start""right-end" | "bottom" |
TourLabels
Text overrides. Every label defaults to the translated built-in text.
| Prop | Type | Default |
|---|---|---|
back | string | "Back" |
next | string | "Continue" |
finish | string | "Finish" |
closeAccessible name of the close button. | string | "Close" |
stepProgress text, e.g. | (step: number, total: number) => string | "Step 2 of 4" |