Tour
A guided tour over the page, driven from props or from code, with steps that wait, skip, move on by themselves and remember where the reader got to.
Import
import { Tour } from '@vitral/vue';Basic
`v-model:open` starts and ends it. The arrow keys move between steps, Escape ends it, and each popover is a dialog a screen reader reads as it arrives.
Progress, sides and the overlay
`progressStyle` draws the progress as text, dots or a bar; `side` and `align` place the popover; `overlayClickBehavior="nextStep"` makes a press on the dimmed page move on.
Steps that wait and move on by themselves
`advanceOn` moves on when the reader does what the step asks, `beforeShow` is waited for before a step shows, `waitFor` waits for an element that is not there yet, and `when` leaves out a step that does not apply.
Motion, placement and scrolling
Off by default: `animate` moves the highlight from step to step and fades each popover in, over `animation-duration` milliseconds. `side: 'auto'` puts the popover wherever there is room, and with `arrow` the pointer follows. `scroll-into-view` brings each element into view — `smooth-scroll` for a smooth ride — and off, the page stays put while the popover stays on the screen.
Across pages
A step can name its `page`. Reaching one on another page goes there first: through `navigate` when there is a router (here a stand-in for one), or by loading the page, a `<Tour>` there picking the tour up by itself (`resume()` without Vue).
One tour for the whole app
`useGlobalTour()` returns the application's own tour, the same one from any component: it belongs to the app rather than to the page that started it, so an onboarding that walks through several screens carries on across route changes. The plugin's `tour` option sets what every tour starts from — `<Tour>`, `useTour()` and this one — and each tour's own props go over it.
From code
`useTour()` returns the tour itself — `drive()`, `moveNext()`, `highlight()`, `destroy()` — and here `highlight()` shows one element on its own.
API
Read from packages/vue/src/components/Tour/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| steps | TourStep[] | — |
| animate | boolean | Move the highlight from step to step and fade each popover in. Off by default. |
| animationDuration | number | How long a move takes when `animate` is on, in milliseconds. Defaults to 300. |
| overlayColor | string | — |
| overlayOpacity | number | — |
| smoothScroll | boolean | — |
| scrollIntoView | boolean | Bring each step's element into view. Defaults to true; off, the page stays put and the popover stays on screen. |
| scrollBlock | 'start' | 'center' | 'end' | 'nearest' | Where a scrolled-to element ends up. Defaults to `'center'`. |
| keepInView | boolean | Keep the popover on the screen even when its element is not. Defaults to true. |
| navigate | (page: string) => void | Promise<unknown> | Goes to another page for a step whose `page` is not this one — a router's `push`: `(page) => router.push(page)`. Without it, the page is loaded, and a `<Tour>` there picks the tour up by itself. |
| allowClose | boolean | Escape, the close button and a press on the overlay end the tour. Defaults to true. |
| overlayClickBehavior | 'close' | 'nextStep' | — |
| dismissableMask | boolean | `false` keeps a press on the overlay from ending the tour, as on a dialog's mask. Defaults to true. |
| arrow | boolean | A pointer from the popover to the element. Off by default. |
| stagePadding | number | The gap around the element, in pixels. Defaults to 2, so the highlight hugs it. |
| stageRadius | number | The corner of the gap. Defaults to the element's own corner, grown by the padding. |
| disableActiveInteraction | boolean | — |
| allowKeyboardControl | boolean | Defaults to true. |
| popoverClass | string | — |
| popoverOffset | number | — |
| showButtons | TourButton[] | — |
| disableButtons | TourButton[] | — |
| showProgress | boolean | — |
| progressText | string | `'{current} of {total}'`; the locale's otherwise. |
| progressStyle | TourProgressStyle | — |
| nextBtnText | string | — |
| prevBtnText | string | — |
| doneBtnText | string | — |
| allowHtml | boolean | Titles and descriptions are HTML. Only for text you wrote. |
| elementTimeout | number | How long a step waits for its element to appear, in milliseconds. |
| missingElement | 'center' | 'skip' | — |
| storageKey | string | Remembers where the reader got to, and whether they finished, under this key. |
| options | TourConfig | Everything else `createTour` takes: the hooks, `storage`, `dir`. |
| appendTo | string | HTMLElement | — |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Slots
| Name | Slot props | Description |
|---|---|---|
| content | (context: TourStepContext) | Drawn in the popover below the description, for every step. |