Skip to content

Step

A step represents a single tooltip, spotlight, or action in a tour.

Type

ts
interface Step {
  id: string
  target?: string | Element | null
  content: StepContent | (() => StepContent | Promise<StepContent>)
  placement?: PopoverPlacement
  showIf?: (ctx: unknown) => boolean
  clickThrough?: boolean
  scrollIntoView?: boolean
  actions?: StepAction[]
}

Fields

FieldTypeDefaultDescription
idstringUnique step identifier (required)
targetstring | Element | nullnullCSS selector or DOM element to anchor to
contentStepContent | () => StepContentStep content (required)
placementPopoverPlacement'bottom'Tooltip position relative to target
showIf(ctx) => booleanundefinedConditionally skip this step
clickThroughbooleanfalseAllow clicks through the spotlight overlay
scrollIntoViewbooleantrueAuto-scroll target into view
actionsStepAction[]Default buttonsCustom action buttons

StepContent

ts
interface StepContent {
  title?: string
  body?: string
  html?: string
}

StepAction

ts
interface StepAction {
  label: string
  action: 'next' | 'prev' | 'skip' | 'end' | (string & {})
}

PopoverPlacement

ts
type PopoverPlacement =
  | 'top' | 'top-start' | 'top-end'
  | 'bottom' | 'bottom-start' | 'bottom-end'
  | 'left' | 'left-start' | 'left-end'
  | 'right' | 'right-start' | 'right-end'
  | 'center'

Examples

Basic Step

ts
{ id: 'intro', content: { title: 'Welcome!', body: 'Let us show you around.' }, target: '#app' }

Async Content

ts
{
  id: 'dynamic',
  content: async () => ({
    title: await fetchGreeting(),
    body: 'Personalised content loaded.',
  }),
  target: '#header',
}

Conditional Step

ts
{
  id: 'admin-only',
  content: { title: 'Admin Settings' },
  target: '#admin-panel',
  showIf: (ctx) => ctx.roles?.includes('admin'),
}

Released under the MIT License.