Vue Shepherd

6.0.0 · active · verified Sun Apr 19

Vue Shepherd is a Vue wrapper library for Shepherd.js, a robust JavaScript library designed for guiding users through applications with interactive site tours. The package is currently at its stable version 6.0.0 and offers integration for both Vue's Composition API via `useShepherd` and Options API using `VueShepherdPlugin`. It differentiates itself by providing a native Vue experience for Shepherd.js, simplifying the process of adding step-by-step guides within Vue applications. The release cadence is moderate, often aligning with updates to the underlying Shepherd.js library and broader Vue ecosystem evolutions. A critical aspect for adopters is the licensing; starting from v5.0.1, the library transitioned to the AGPL-3.0 license, which necessitates a commercial license for commercial products and revenue-generating companies.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to set up a basic site tour using the Composition API with `useShepherd`, attach a step to an element, and start the tour, including the necessary CSS import.

import { createApp, ref, onMounted } from 'vue';
import { useShepherd } from 'vue-shepherd';
import 'shepherd.js/dist/css/shepherd.css';

const App = {
  setup() {
    const el = ref(null);

    const tour = useShepherd({
      useModalOverlay: true,
      defaultStepOptions: {
        cancelIcon: {
          enabled: true
        }
      }
    });

    onMounted(() => {
      tour.addStep({
        id: 'intro',
        attachTo: { element: el.value, on: 'top' },
        text: 'This is your first step! Click next to continue.',
        buttons: [
          { action: tour.cancel, text: 'Exit' },
          { action: tour.next, text: 'Next' }
        ]
      });

      tour.addStep({
        id: 'second',
        text: 'This step demonstrates a modal overlay and custom buttons.',
        buttons: [
          { action: tour.back, text: 'Back' },
          { action: tour.complete, text: 'Done' }
        ]
      });

      tour.start();
    });

    return { el };
  },
  template: `
    <div id="app">
      <h1>Welcome to Vue Shepherd!</h1>
      <div ref="el" style="border: 1px solid blue; padding: 20px; margin-top: 50px;">
        Content for the tour step.
      </div>
    </div>
  `
};

createApp(App).mount('#app');

view raw JSON →