vael-ui v0.5.7

Overlays

Layout

Tour

A guided walkthrough that highlights one element at a time next to a callout. Use it for onboarding and product tours.

Install

import { Tour } from 'vael-ui'

Playground

Placement, behaviour and animation

Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Tour } from 'vael-ui'

const steps = [
  { target: '#first', title: 'First stop', description: 'Starts here.' },
  { target: '#second', title: 'Second stop', description: 'And ends here.' },
]
const open = ref(false)
</script>

<template>
  <Tour v-model:open="open" :steps="steps" />
</template>

Props

NameTypeDefaultDescription
stepsRequiredreadonly T[]Steps to walk through, in order: { target, title, description }, where target is the element (or a selector) the step points at. A step can also set its callout's side, align and spotlight, and a group for "Section 2 of 3".
idstringIdentifies this tour instance (see useTour's id option).
modalbooleantrueScroll-locks the page and makes everything but the target and callout inert while open.
closeOnEscbooleantrueEscape key closes the tour, firing @skip.
closeOnOverlaybooleanfalseClicking the dimmed area closes the tour.
keyboardNavbooleantrueArrowLeft and ArrowRight move back and forward a step, swapped right to left.
spotlightPaddingnumber4Space between the target and the spotlight cutout, in pixels. Per-step spotlightPadding wins.
spotlightRadiusnumber8Spotlight cutout corner radius, in pixels. Per-step spotlightRadius wins.
scrollIntoViewbooleantrueScrolls the target into view on every step change.
teleportTostring | HTMLElementTeleport target: a CSS selector or element. Wins over container either way.
containerDOMTargetScopes the tour to an element. The spotlight dims only that box and the callout teleports there. Scroll lock and inert apply only inside it. Omit it for a page-level tour.
scrollTargetDOMTargetElement to scroll-lock while open. Defaults to container, then document.body.
forceMountbooleanfalseKeeps it mounted while closed, toggled with v-show, so its content keeps its state. vael-ui then leaves its motion to you.
beforeCloseBeforeClose<PopoverCloseReason>Runs before the tour closes. Return true to close it, false to keep it open, or a promise of either, like () => confirmAction(…).result. The tour stays open while the promise is pending.
motionTourMotiontrueHow the callout moves, like Popover's, and whether the spotlight glides between steps. false turns both off, so you can animate spotlightEl yourself. An object moves the callout your way: values for the panel part, { spring }, or enter / leave hooks. Its { duration, easing } or { spring } also times the glide between steps. Unset, the glide is quick to a nearby target and longer across the screen.
uiPartial<Record<'spotlight' | 'positioner' | 'panel', UiPartValue>>Class and style overrides for each part.
openbooleanfalseWhether the tour is open.
stepnumber0Current step index; resets to the first step whenever the tour opens.

Events

NameTypeDescription
open-change(value: boolean, details: PopoverOpenChangeDetails)Fires when a close is requested; call details.cancel() to keep the tour open.
skip(details: TourEndDetails<T>)Fires when the tour ends early: the Skip button, Escape, or the step's target disappearing.
step-change(details: TourStepChangeDetails<T>)Fires after moving to a step, including the first. The new step renders by the next frame.
finish(details: TourEndDetails<T>)Fires when the tour advances past the last step.
update:open(value: boolean)Fires when open changes (v-model:open).
update:step(value: number)Fires when step changes (v-model:step).

Slots

NameTypeDescription
default{ id: string | undefined; step: T | undefined; index: number; total: number; group: string | undefined; groups: TourGroup<T>[]; isFirst: boolean; isLast: boolean; isTransitioning: boolean; next: () => Promise<void>; prev: () => Promise<void>; skip: () => void; close: () => void; panelEl: HTMLElement | null; }Replaces the callout content; receives the current step, progress and next/prev/skip/close.

Exposed

NameTypeDescription
id() => stringReturns the tour's id prop.
targetElHTMLElement | nullCurrent step's target element.
panelElHTMLElement | nullCallout panel element (null while closed).
positionerElHTMLElement | nullPositioning wrapper around the callout panel (null while closed).
spotlightElHTMLElement | nullDimmed overlay with the cutout (null while closed). It carries the cutout's box, kept current through the glide: --ui-tour-cutout-x, -y, -width, -height and -radius, in px.
isClosingbooleantrue while a beforeClose close is pending.
close() => voidCloses the tour, running @open-change and beforeClose first.
cancelClose() => voidCancels a close pending in beforeClose and keeps the tour open.
currentIndexnumberCurrent step index.
isTransitioningbooleantrue while a step's onBeforeEnter is pending; the previous step stays visible until it settles.
next() => Promise<void>Goes to the next step, or finishes the tour on the last one.
prev() => Promise<void>Goes back one step.
skip() => voidCloses the tour and fires @skip.

Motion New

Tour's motion: the callout opens and closes like Popover's. Its timing, { duration, easing } or { spring }, also sets how the spotlight and the callout glide between steps. Unset, the glide is quick to a nearby target and longer across the screen. false turns it all off.

<Tour
  :motion="{
    initial: { panel: { opacity: 0, y: 8, scale: 0.98 } },
    spring: { damping: 0.85, response: 0.35 },
  }"
/>
NameTypeDescription
initialexitpositionerpanelSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
morphlinkedexitOrder'trigger' | Record<string, LinkedMotion> | 'reverse'morph: 'trigger' grows it out of the element that opened it. linked moves other elements with it, such as the page receding behind it. exitOrder: 'reverse' closes its children first.
swapresize'sync' | 'wait' | booleanContent that changes while it's open crossfades ('sync') or waits for the old view to leave ('wait'), and the box eases to its new size unless resize: false.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

KeyAction
ArrowRightGoes to the next step.
ArrowLeftGoes to the previous step.
TabShiftTabMoves focus within the callout, wrapping at the ends, when modal is on.
EscapeEnds the tour and fires @skip, unless closeOnEsc is false.
  • The callout has role="dialog". Its visible title names it through aria-labelledby and its description through aria-describedby; with a custom slot or no title, it gets an aria-label from the step’s title, else the translated “Step {current} of {total}”. With modal, it sets aria-modal only when the target can’t be used (disableInteraction).
  • Focus moves to an [autofocus] element in the callout on open and on every step change, else the Next button, else the first focusable element. When the tour ends, focus returns to the element that started it.
  • With modal (default), everything but the target and the callout is inert, and Tab cycles through the callout, then the target’s controls.
  • Arrow keys are ignored while focus is in a field or a widget that uses them, and keyboardNav: false turns them off. Right to left, ArrowLeft and ArrowRight swap.