useTour New
Usage
Use the auto-imported useTour composable to drive a guided tour with a single Popover whose anchor moves between steps. The composable owns the step state and resolves each step's target into a reference you bind to <B24Popover>, while you keep full control over the content and navigation.
Dashboard
Overview of your workspace.
Profile
Manage your account.
Settings
Configure your preferences.
Each step requires a target that the popover anchors to. It accepts a CSS selector, an element, a virtual element (anything with getBoundingClientRect), or a ref/getter returning one of those. Pass null to anchor the step to the center of the viewport. Any other field on a step (title, body, side, …) is passed through untouched and available via current.
<script setup lang="ts">
const card = useTemplateRef('card')
const tour = useTour([
{ target: '#cta', title: 'Get started' },
{ target: () => card.value, title: 'Profile', side: 'right' },
{ target: null, title: 'All set' }
])
</script>
<template>
<B24Button @click="tour.start()">Start tour</B24Button>
<B24Popover :open="tour.open.value" :reference="tour.reference.value" :dismissible="false">
<template #content>
<!-- your content + buttons -->
<B24Button :disabled="!tour.hasPrev.value" @click="tour.prev()">Back</B24Button>
<B24Button @click="tour.next()">{{ tour.hasNext.value ? 'Next' : 'Finish' }}</B24Button>
</template>
</B24Popover>
</template>
- Built on the Popover's reactive
referenceprop, so the popover smoothly repositions when the active step changes. - The active target is scrolled into view automatically when a step becomes active.
- Since you render the content yourself, there is no extra theme or locale to maintain.
API
useTour(steps, options?)
Parameters
ref, or a getter for reactive steps.'#id', '.class', or a bare id resolved as #id), an element, a virtual element, or a ref/getter returning one. Use null to center the step in the viewport.title, body, side, …) are passed through and available via current.Return
undefined when there are no steps.<B24Popover :reference>.loop option.