PXD

Tour

Guide users through a product by highlighting a target element step by step.

Default

<script setup>
import { ref } from "vue"

const current = ref(0)
const isVisible = ref(false)

const steps = [
  {
    target: () => document.querySelector("[data-demo-tour-target]"),
    title: "Search anything",
    description: "Find components, tokens and guidance from here.",
  },
  {
    target: () => document.querySelector("[data-demo-tour-target-2]"),
    title: "Copy the snippet",
    description: "Every demo ships with copy-ready code.",
    position: "top",
  },
]

function openTour() {
  current.value = 0
  isVisible.value = true
}
</script>

<template>
  <PStack gap="2">
    <PButton @click="openTour">Start tour</PButton>

    <PButton data-demo-tour-target>Search</PButton>
    <PButton data-demo-tour-target-2 variant="primary">Copy</PButton>

    <PTour v-model="isVisible" v-model:current="current" :steps="steps" />
  </PStack>
</template>

Props

NameTypeDefaultDescription
model-valuebooleanfalseWhether the tour is visible
currentnumber0Index of the active step, supports v-model:current
stepsTourStep[]-Steps to walk through
z-indexnumber10Stacking order of the overlay, highlight frame and bubble
show-skipbooleantrueShow the skip button in the bubble
show-progressbooleantrueShow the current / total counter in the bubble

TourStep

NameTypeDescription
targetstring | HTMLElement | (() => HTMLElement | null)Element to highlight; omitting it shows a centred intro panel
titlestringBubble title
descriptionstringBubble description
positionComponentPositionPlacement of the bubble relative to the target
next-textstringLabel of the next button
prev-textstringLabel of the previous button
before-enter(ctx: { index: number, step: TourStep }) => void | Promise<void>Runs before the step target is resolved, awaited when it returns a promise

Events

NameTypeDescription
update:model-value(value: boolean) => voidEmitted when the visibility changes.
update:current(value: number) => voidEmitted when the active step index changes.
change(index: number, step: TourStep) => voidEmitted when the tour moves to another step.
finish() => voidEmitted when the last step is completed or the tour is closed from it.
skip() => voidEmitted when the skip button is pressed.
error(error: unknown, index: number) => voidEmitted when a step target cannot be resolved or beforeEnter throws.

Methods

NameTypeDescription
next() => voidAdvance to the next step, or finish the tour on the last step.
prev() => voidGo back to the previous step.
goTo(index: number) => voidJump to the step at the given index.
close() => voidClose the tour.

Source

Source