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 }.
Example
Section titled “Example”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();Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Tour(
options?):Tour
Defined in: tour.ts:207
Parameters
Section titled “Parameters”options?
Section titled “options?”TourOptions = {}
Returns
Section titled “Returns”Tour
Overrides
Section titled “Overrides”Properties
Section titled “Properties”bindings
Section titled “bindings”bindings:
Bindings
Defined in: evented.ts:23
The handlers registered through on and once.
Inherited from
Section titled “Inherited from”classPrefix
Section titled “classPrefix”classPrefix:
string
Defined in: tour.ts:167
The classPrefix option, ending in -.
currentStep?
Section titled “currentStep?”
optionalcurrentStep?:Step|null
Defined in: tour.ts:171
The current step. Prefer getCurrentStep().
focusedElBeforeOpen?
Section titled “focusedElBeforeOpen?”
optionalfocusedElBeforeOpen?:HTMLElement|null
Defined in: tour.ts:175
The element to return focus to when the tour ends.
optionalid?:string
Defined in: tour.ts:179
The tour’s id: ${tourName}--${id}.
modal?
Section titled “modal?”
optionalmodal?:ShepherdModalAPI|null
Defined in: tour.ts:183
The overlay controller, once the tour has started.
options
Section titled “options”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
Section titled “trackedEvents”trackedEvents:
string[]
Defined in: tour.ts:162
The names of the events a tour fires most often.
Methods
Section titled “Methods”addStep()
Section titled “addStep()”addStep(
options,index?):Step
Defined in: tour.ts:242
Adds a new step to the tour
Parameters
Section titled “Parameters”options
Section titled “options”An object containing step options or a Step instance
index?
Section titled “index?”number
The optional index to insert the step at. If undefined, the step is added to the end of the array.
Returns
Section titled “Returns”The newly added step
addSteps()
Section titled “addSteps()”addSteps(
steps?):Tour
Defined in: tour.ts:259
Add multiple steps to the tour
Parameters
Section titled “Parameters”steps?
Section titled “steps?”Step[] | StepOptions[]
The steps to add to the tour
Returns
Section titled “Returns”Tour
back()
Section titled “back()”back():
void|Promise<void>
Defined in: tour.ts:272
Go to the previous step in the tour
Returns
Section titled “Returns”void | Promise<void>
cancel()
Section titled “cancel()”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.
Returns
Section titled “Returns”Promise<void>
complete()
Section titled “complete()”complete():
void
Defined in: tour.ts:325
Calls _done() triggering the complete event
Returns
Section titled “Returns”void
getById()
Section titled “getById()”getById(
id):Step|undefined
Defined in: tour.ts:334
Gets the step from a given id
Parameters
Section titled “Parameters”string | number
The id of the step to retrieve
Returns
Section titled “Returns”Step | undefined
The step corresponding to the id
getCurrentStep()
Section titled “getCurrentStep()”getCurrentStep():
Step|null|undefined
Defined in: tour.ts:341
Gets the current step
Returns
Section titled “Returns”Step | null | undefined
hide()
Section titled “hide()”hide():
void|undefined
Defined in: tour.ts:348
Hide the current step
Returns
Section titled “Returns”void | undefined
isActive()
Section titled “isActive()”isActive():
boolean
Defined in: tour.ts:358
Check if the tour is active
Returns
Section titled “Returns”boolean
next()
Section titled “next()”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
Returns
Section titled “Returns”void | Promise<void>
off(
event,handler?):Tour
Defined in: evented.ts:64
Removes an event listener for the given event string.
Parameters
Section titled “Parameters”string
handler?
Section titled “handler?”Returns
Section titled “Returns”Tour
Inherited from
Section titled “Inherited from”on(
event,handler,ctx?,once?):Tour
Defined in: evented.ts:34
Adds an event listener for the given event string.
Parameters
Section titled “Parameters”string
handler
Section titled “handler”unknown
boolean = false
Returns
Section titled “Returns”Tour
Inherited from
Section titled “Inherited from”once()
Section titled “once()”once(
event,handler,ctx?):Tour
Defined in: evented.ts:53
Adds an event listener that only fires once for the given event string.
Parameters
Section titled “Parameters”string
handler
Section titled “handler”unknown
Returns
Section titled “Returns”Tour
Inherited from
Section titled “Inherited from”removeStep()
Section titled “removeStep()”removeStep(
name):void
Defined in: tour.ts:380
Removes the step from the tour
Parameters
Section titled “Parameters”string
The id for the step to remove
Returns
Section titled “Returns”void
setupModal()
Section titled “setupModal()”setupModal():
void
Defined in: tour.ts:565
setupModal create the modal container and instance
Returns
Section titled “Returns”void
show()
Section titled “show()”show(
key?,forward?):void|Promise<void>
Defined in: tour.ts:410
Show a specific step in the tour
Parameters
Section titled “Parameters”string | number = 0
The key to look up the step by
forward?
Section titled “forward?”boolean = true
True if we are going forward, false if backward
Returns
Section titled “Returns”void | Promise<void>
A promise when the step’s waitForElement option makes showing
asynchronous, otherwise undefined
start()
Section titled “start()”start():
Promise<void>
Defined in: tour.ts:486
Start the tour
Returns
Section titled “Returns”Promise<void>
trigger()
Section titled “trigger()”trigger(
event, …args):Tour
Defined in: evented.ts:87
Triggers an event listener for the given event string.
Parameters
Section titled “Parameters”string
…any[]
Returns
Section titled “Returns”Tour