Skip to content

Tour

Defined in: tour.ts:158

Class representing the site tour.

Fires start, active, show, complete, cancel and inactive. A show handler receives { step, previous }.

import Shepherd from 'shepherd.js';
import 'shepherd.js/dist/css/shepherd.css';
const tour = new Shepherd.Tour({ useModalOverlay: true });
tour.addStep({
title: 'Save',
text: 'Saves your work.',
attachTo: { element: '#save', on: 'bottom' },
buttons: [{ text: 'Done', action: 'complete' }]
});
tour.start();

new Tour(options?): Tour

Defined in: tour.ts:207

TourOptions = {}

Tour

Evented.constructor

bindings: Bindings

Defined in: evented.ts:23

The handlers registered through on and once.

Evented.bindings


classPrefix: string

Defined in: tour.ts:167

The classPrefix option, ending in -.


optional currentStep?: Step | null

Defined in: tour.ts:171

The current step. Prefer getCurrentStep().


optional focusedElBeforeOpen?: HTMLElement | null

Defined in: tour.ts:175

The element to return focus to when the tour ends.


optional id?: string

Defined in: tour.ts:179

The tour’s id: ${tourName}--${id}.


optional modal?: ShepherdModalAPI | null

Defined in: tour.ts:183

The overlay controller, once the tour has started.


options: TourOptions

Defined in: tour.ts:187

The options the tour was created with, plus defaults.


steps: Step[]

Defined in: tour.ts:191

The tour’s steps, in order.


trackedEvents: string[]

Defined in: tour.ts:162

The names of the events a tour fires most often.

addStep(options, index?): Step

Defined in: tour.ts:242

Adds a new step to the tour

Step | StepOptions

An object containing step options or a Step instance

number

The optional index to insert the step at. If undefined, the step is added to the end of the array.

Step

The newly added step


addSteps(steps?): Tour

Defined in: tour.ts:259

Add multiple steps to the tour

Step[] | StepOptions[]

The steps to add to the tour

Tour


back(): void | Promise<void>

Defined in: tour.ts:272

Go to the previous step in the tour

void | Promise<void>


cancel(): Promise<void>

Defined in: tour.ts:284

Calls _done() triggering the ‘cancel’ event If confirmCancel is true, will show a window.confirm before cancelling If confirmCancel is a function, will call it and wait for the return value, and only cancel when the value returned is true. A promise is waited on the same way.

Promise<void>


complete(): void

Defined in: tour.ts:325

Calls _done() triggering the complete event

void


getById(id): Step | undefined

Defined in: tour.ts:334

Gets the step from a given id

string | number

The id of the step to retrieve

Step | undefined

The step corresponding to the id


getCurrentStep(): Step | null | undefined

Defined in: tour.ts:341

Gets the current step

Step | null | undefined


hide(): void | undefined

Defined in: tour.ts:348

Hide the current step

void | undefined


isActive(): boolean

Defined in: tour.ts:358

Check if the tour is active

boolean


next(): void | Promise<void>

Defined in: tour.ts:366

Go to the next step in the tour If we are at the end, call complete

void | Promise<void>


off(event, handler?): Tour

Defined in: evented.ts:64

Removes an event listener for the given event string.

string

AnyHandler

Tour

Evented.off


on(event, handler, ctx?, once?): Tour

Defined in: evented.ts:34

Adds an event listener for the given event string.

string

AnyHandler

unknown

boolean = false

Tour

Evented.on


once(event, handler, ctx?): Tour

Defined in: evented.ts:53

Adds an event listener that only fires once for the given event string.

string

AnyHandler

unknown

Tour

Evented.once


removeStep(name): void

Defined in: tour.ts:380

Removes the step from the tour

string

The id for the step to remove

void


setupModal(): void

Defined in: tour.ts:565

setupModal create the modal container and instance

void


show(key?, forward?): void | Promise<void>

Defined in: tour.ts:410

Show a specific step in the tour

string | number = 0

The key to look up the step by

boolean = true

True if we are going forward, false if backward

void | Promise<void>

A promise when the step’s waitForElement option makes showing asynchronous, otherwise undefined


start(): Promise<void>

Defined in: tour.ts:486

Start the tour

Promise<void>


trigger(event, …args): Tour

Defined in: evented.ts:87

Triggers an event listener for the given event string.

string

…any[]

Tour

Evented.trigger