Skip to content

Vue 3

GuideFlow provides a Vue 3 plugin and composables for reactive tour management.

Installation

bash
npm install @guideflow/core @guideflow/vue

Plugin Setup

ts
// main.ts
import { createApp } from 'vue'
import { createGuideFlow } from '@guideflow/core'
import { GuideFlowPlugin } from '@guideflow/vue'
import '@guideflow/core/styles'
import App from './App.vue'

const gf = createGuideFlow()
const app = createApp(App)
app.use(GuideFlowPlugin, { instance: gf })
app.mount('#app')

useTour Composable

vue
<script setup lang="ts">
import { useTour } from '@guideflow/vue'

const { start, stop, next, prev, isActive, currentStepIndex, totalSteps } = useTour()

const flow = {
  id: 'welcome',
  initial: 'main',
  states: {
    main: {
      steps: [
        {
          id: 'step-1',
          content: { title: 'Welcome!' },
          target: '#hero',
          placement: 'bottom',
        },
      ],
      final: true,
    },
  },
}
</script>

<template>
  <button @click="start(flow)">Start Tour</button>
  <span v-if="isActive">Step {{ currentStepIndex + 1 }} of {{ totalSteps }}</span>
</template>

useGuideFlow Composable

Access the raw GuideFlow instance:

vue
<script setup lang="ts">
import { useGuideFlow } from '@guideflow/vue'

const gf = useGuideFlow()

// Access hotspots, hints, events directly
gf.hotspot('#new-feature', {
  title: 'New!',
  body: 'Check out this feature.',
})
</script>

API Reference

GuideFlowPlugin

OptionTypeDescription
instanceGuideFlowInstanceThe GuideFlow instance to provide

useTour()

ReturnTypeDescription
start(flow)functionStart a tour
stop()functionStop the active tour
next()functionAdvance to next step
prev()functionGo to previous step
isActiveRef<boolean>Whether a tour is running
currentStepIndexRef<number>Current step index
totalStepsRef<number>Total steps in tour

useGuideFlow()

Returns the GuideFlowInstance from the plugin injection.

Released under the MIT License.