Skip to content

StepOptions

Defined in: step.ts:40

The options for the step

optional advanceOn?: StepOptionsAdvanceOn

Defined in: step.ts:70

An action on the page which should advance shepherd to the next step. It should be an object with a string selector and an event name

const step = new Step(tour, {
advanceOn: { selector: '.some .selector-path', event: 'click' },
...moreOptions
});

event doesn’t have to be an event inside the tour, it can be any event fired on any element on the page. You can also always manually advance the Tour by calling myTour.next().


optional arrow?: boolean | StepOptionsArrow

Defined in: step.ts:75

Whether to display the arrow for the tooltip or not, or options for the arrow.


optional attachTo?: StepOptionsAttachTo

Defined in: step.ts:56

The element the step should be attached to on the page. An object with properties element and on.

const step = new Step(tour, {
attachTo: { element: '.some .selector-path', on: 'left' },
...moreOptions
});

If you don’t specify an attachTo the element will appear in the middle of the screen. If you omit the on portion of attachTo, the element will still be highlighted, but the tooltip will appear in the middle of the screen, without an arrow pointing to the target.


optional beforeShowPromise?: () => Promise<unknown>

Defined in: step.ts:88

A function that returns a promise. When the promise resolves, the rest of the show code for the step will execute. Pass the function, not a promise: a promise starts its work when the tour is defined, and is ignored.

Promise<unknown>

beforeShowPromise: () => openSettingsPanel()

optional buttons?: readonly StepOptionsButton[]

Defined in: step.ts:95

An array of buttons to add to the step. These will be rendered in a footer below the main body text. A step’s buttons replace the ones from defaultStepOptions; they are not merged.


optional cancelIcon?: StepOptionsCancelIcon

Defined in: step.ts:105

Should a cancel “✕” be shown in the header of the step?

cancelIcon: { enabled: true }

optional canClickTarget?: boolean

Defined in: step.ts:114

A boolean, that when set to false, will set pointer-events: none on the target.

The blocking is delivered by shepherd.css (via the shepherd-target-click-disabled class), so it has no effect if you have opted out of Shepherd’s stylesheet without providing an equivalent rule.


optional classes?: string

Defined in: step.ts:119

A string of extra classes to add to the step’s content element.


optional data?: Record<string, unknown>

Defined in: step.ts:128

Arbitrary, JSON-serializable data to associate with the step. Shepherd does not use this value internally; it is a place to store your own metadata (for example analytics ids, or context produced by a tour generator) and read it back from step.options.data in event handlers and button actions.


optional extraHighlights?: readonly string[]

Defined in: step.ts:141

An array of extra element selectors to highlight when the overlay is shown The tooltip won’t be fixed to these elements, but they will be highlighted just like the attachTo element.

const step = new Step(tour, {
extraHighlights: [ '.pricing', '#docs' ],
...moreOptions
});

optional highlightClass?: string

Defined in: step.ts:147

An extra class to apply to the attachTo element when it is highlighted (that is, when its step is active). You can then target that selector in your CSS.


optional id?: string

Defined in: step.ts:152

The string to use as the id for the step.


optional label?: StringOrStringFunction

Defined in: step.ts:171

The aria-label for the step’s dialog, used to give the step an accessible name when it has no visible title. A step with neither gets no naming attribute at all, so its dialog has no accessible name and screen readers announce it without one.

- string
- `Function` to be executed when the step is built. It must return a string.

Ignored when title is set: the title already supplies the accessible name via aria-labelledby, which outranks aria-label in the accessible name computation. In that case a function-valued label is not invoked at all.

An empty or whitespace-only value omits the attribute rather than emitting an accessible name that assistive technology treats as empty.


optional modalOverlayOpeningPadding?: number

Defined in: step.ts:176

An amount of padding to add around the modal overlay opening


optional modalOverlayOpeningRadius?: number | { bottomLeft?: number; bottomRight?: number; topLeft?: number; topRight?: number; }

Defined in: step.ts:181

An amount of border radius to add around the modal overlay opening


optional modalOverlayOpeningXOffset?: number

Defined in: step.ts:193

An amount to offset the modal overlay opening in the x-direction


optional modalOverlayOpeningYOffset?: number

Defined in: step.ts:198

An amount to offset the modal overlay opening in the y-direction


optional positionOptions?: StepOptionsPosition

Defined in: step.ts:211

How the step is placed against its target: the gap, the distance kept from the edges, the CSS position, and whether it may flip. See StepOptionsPosition. Values from defaultStepOptions and the step combine key by key, so a step can change one and keep the rest.

positionOptions: { offset: 12, padding: 8 }

optional scrollTo?: boolean | ScrollIntoViewOptions

Defined in: step.ts:216

Should the element be scrolled to when this step is shown?


optional scrollToHandler?: (element) => void

Defined in: step.ts:222

A function that lets you override the default scrollTo behavior and define a custom action to do the scrolling, and possibly other logic.

HTMLElement

void


optional showOn?: () => boolean

Defined in: step.ts:228

A function that, when it returns true, will show the step. If it returns false, the step will be skipped.

boolean


optional skipMissingElement?: boolean

Defined in: step.ts:246

When true, a step whose attachTo.element selector (or function locator) does not resolve to an element in the DOM is skipped, advancing to the next step (or the previous step when navigating backwards) instead of being shown centered. If all remaining steps are skipped, the tour completes (going forward) or cancels (going backward), mirroring the showOn semantics. Can be set on defaultStepOptions to apply to every step. Combine with waitForElement to give the element time to appear before skipping. Steps without an attachTo element are never skipped, since they are intentionally centered.

Note that the target is looked up before the step’s own beforeShowPromise and before-show handlers run, so an element that those handlers create is not visible to this check. Use beforeShowPromise on its own for targets the step itself renders.


optional text?: StepText

Defined in: step.ts:258

The text in the body of the step. Strings render as HTML, so escape untrusted input. It can be one of four types:

- HTML string
- Array of HTML strings
- `HTMLElement` object
- `Function` to be executed when the step is built. It must return one of the three options above.

optional title?: StringOrStringFunction

Defined in: step.ts:268

The step’s title. It becomes an h3 at the top of the step. Strings render as HTML, so escape untrusted input.

- HTML string
- `Function` to be executed when the step is built. It must return HTML string.

optional waitForElement?: number

Defined in: step.ts:282

The maximum amount of time, in milliseconds, to wait for the attachTo.element to appear in the DOM before showing the step. The DOM is watched with a MutationObserver, so the step attaches as soon as the element appears. If the timeout expires, the step falls back to its default behavior: skipped when skipMissingElement is true, otherwise shown centered.

The wait starts before the step’s own beforeShowPromise and before-show handlers run, so it cannot observe a target that those handlers create, and a function locator is re-evaluated on each DOM change until it resolves.


optional when?: StepOptionsWhen

Defined in: step.ts:294

You can define show, hide, etc events inside when. For example:

when: {
show: function() {
window.scrollTo(0, 0);
}
}