Vue API reference
The Vue adapter (@glowhop/vue-tour) exports components, hooks, and utility functions.
useGlowTour(source?)
Section titled “useGlowTour(source?)”Runs a tour from a component. This is the main entry point: it returns the tour to render, its methods, and one readonly ref per state field.
Signature:
function useGlowTour(source?: GlowTourOptions | Tour): UseGlowTourResult
type UseGlowTourResult = Pick<Tour, "advance" | "cancel" | "create" | "goTo" | "hidePopover" | "previous" | "showPopover" | "start"> & { readonly tour: Tour} & { readonly [K in keyof TourState]: Readonly<Ref<TourState[K]>> }Parameters:
source- Options for a new tour, or an existing tour created withcreateGlowTour()to share it.
With options, the tour is disposed when the calling effect scope is disposed. With a tour, the composable only reads it and never disposes it.
Usage:
<script setup lang="ts">import { GlowTourDefault, useGlowTour } from "@glowhop/vue-tour";
const { tour, create, start, status } = useGlowTour();const workflow = create("welcome") .step({ id: "search", target: '[data-tour="search"]', content: "Find anything here." }) .build();</script>
<template> <button :disabled="status === 'active'" @click="start(workflow)">Start tour</button> <GlowTourDefault :tour="tour" /></template>See the guide to choose step targets and share one tour between components.
useGlowTourContext()
Section titled “useGlowTourContext()”Reads the state of the tour rendered by the enclosing GlowTourRoot, to build tour UI inside the root. To run a tour or read its state elsewhere, use useGlowTour.
Returns reactive tour state as a ref. Must be called inside <GlowTourRoot tour={...}>.
Signature:
function useGlowTourContext(): ShallowRef<TourState<VueTourContent>>Returns:
ShallowRef<{ name: string totalSteps: number currentStepIndex: number currentStep: TourCurrentStep<VueTourContent> | null direction: "advance" | "previous" canAdvance: boolean canPrevious: boolean canCancel: boolean isFirstStep: boolean isLastStep: boolean status: "idle" | "starting" | "transitioning" | "active" | "finished" | "cancelled" | "error" | "disposed" error: Error | null}>Usage:
<script setup>import { useGlowTourContext } from "@glowhop/vue-tour";
const state = useGlowTourContext();</script>
<template> <p>Step {{ state.currentStepIndex + 1 }} of {{ state.totalSteps }}</p></template>Functions
Section titled “Functions”createGlowTour(options?)
Section titled “createGlowTour(options?)”Creates a tour instance to share between components, passed to useGlowTour(tour), or to drive outside components. Inherited from Core.
Signature:
function createGlowTour(options?: GlowTourOptions): TourComponents
Section titled “Components”GlowTourDefault
Section titled “GlowTourDefault”Complete tour: overlay, pointer, popover, header, content, and the three navigation controls.
Props:
interface GlowTourDefaultProps { tour: Tour idPrefix?: string // Prefix for internal element IDs}Usage:
<GlowTourDefault :tour="tour" />Composition components
Section titled “Composition components”Primitives for custom layouts:
GlowTourRoot- Root containerGlowTourOverlay- Backdrop overlayGlowTourPointer- Decorative pointer indicator (not the popover arrow)GlowTourPopover- Dialog containerGlowTourHeader- Title areaGlowTourContent- Description areaGlowTourFooter- Navigation button containerGlowTourAdvanceTrigger- Next step buttonGlowTourPreviousTrigger- Previous step buttonGlowTourCancelTrigger- Cancel button, labelled “Skip” by default
The same components are grouped under the GlowTour object without their prefix (Root, Overlay, Pointer, Popover, Header, Content, Footer, AdvanceTrigger, PreviousTrigger, CancelTrigger), for compound markup:
<script setup>import { GlowTour } from "@glowhop/vue-tour";</script>
<template> <GlowTour.Root :tour="tour"> <GlowTour.Popover> <GlowTour.Content /> </GlowTour.Popover> </GlowTour.Root></template>GlowTourDefault is not part of the GlowTour object. The named exports stay the tree-shakeable choice: using GlowTour includes every composition component in your bundle.
Component props
Section titled “Component props”Every composition component must be rendered inside GlowTourRoot, which is the only one that receives the tour. Attributes that are not props (class, style, data-*, listeners, …) are forwarded to the rendered element, except the attributes each component manages itself, such as id and its ARIA relationships.
| Component | Renders | Props | Slot |
|---|---|---|---|
GlowTourRoot |
<section> |
tour: Tour (required), idPrefix?: string |
default |
GlowTourOverlay |
<svg> |
ariaHidden?: boolean (default true), focusable?: string (default "false"), viewBox?: string (default "0 0 0 0") |
default, extra SVG content |
GlowTourPointer |
<div> |
directionContent?: PointerDirectionContent |
- |
GlowTourPopover |
<section> |
role?: string (default "dialog") |
default |
GlowTourHeader |
<header> |
- | - (renders the step title, and nothing when the step has no title) |
GlowTourContent |
<div> |
ariaLive?: string (default "polite") |
- (renders the step content) |
GlowTourFooter |
<footer> |
- | default |
GlowTourPreviousTrigger |
<button> |
previousLabel?: string (default "Previous step"), ariaLabel?: string |
default, trigger slot |
GlowTourAdvanceTrigger |
<button> |
advanceLabel?: string (default "Advance step"), finishLabel?: string (default "Finish tour", on the last step), ariaLabel?: string |
default, trigger slot |
GlowTourCancelTrigger |
<button> |
ariaLabel?: string, cancelLabel?: string (default "Skip") |
default, trigger slot |
idPrefix sets the prefix of the ids the root generates for ARIA relationships. Set it when a page renders several tours.
Triggers: the label is the button text and, without ariaLabel or an aria-label attribute, its accessible name. The default slot replaces the button text and receives the trigger’s button props (disabled, aria-label, …):
<GlowTourAdvanceTrigger advance-label="Next" finish-label="Done" v-slot="{ 'aria-label': label }"> <span class="icon-arrow" aria-hidden="true" /> {{ label }}</GlowTourAdvanceTrigger>A disabled attribute adds to the tour’s own state: a trigger is also disabled when its navigation is not available, or when the step sets its control to "disabled". To hide a trigger, see Hiding a control’s button.
GlowTourPointer
Section titled “GlowTourPointer”Customizes the directional content (emoji or custom content) of the pointer indicator.
interface PointerDirectionContent { top?: VNodeChild bottom?: VNodeChild left?: VNodeChild right?: VNodeChild}Default glyphs (when directionContent is not set):
top:👆bottom:👇left:👈right:👉
Usage (with custom content):
<GlowTourPointer :direction-content="{ top: '⬆️', bottom: '⬇️', left: '⬅️', right: '➡️' }"/>Usage (with custom component):
<GlowTourPointer :direction-content="{ bottom: SomeCustomComponent }"/>Usage (default glyphs):
<GlowTourPointer />Tour- Tour controllerUseGlowTourResult- Value returned byuseGlowTourTourState- Tour stateWorkflowDefinition- Immutable workflowStepPropsStore- Step state storeVueTourContent- Vue content typePointerDirectionContent- Content configuration forGlowTourPointercomponent directionsGlowTourOptions- Options forcreateGlowTourStartOptions- Options fortour.create
