Steppers

Svelte Component

Divide and present content in sequenced steps.

Examples

Step 1 - Get Started!

This example will teach you how to use the Stepper component. Tap next to proceed forward.

Step 2

Step 3

Step 4

Step 5

This example will teach you how to use the Stepper component with horizontal. Tap next to proceed forward.

Usage

To begin, create a writable that will store your active step value. This should always be set to 0 (zero).

typescript
import { writable, type Writable } from 'svelte/store';
typescript
const active: Writable<number> = writable(0);

Scaffold your stepper as shown. If no header slot is provided then the component will add "Step X" text automatically.

html
<Stepper {active} length={2} on:complete={onComplete}>
	<Step index={0}>
		<svelte:fragment slot="header">(header)</svelte:fragment>
		(content)
	</Step>
	<Step index={1} locked={true}>(content)</Step>
</Stepper>

Create a function to handle your Stepper's on:complete event.

typescript
const onComplete: any = () => { /* handle the event */ }

Horizontal Steppers

Create a horizontal stepper by setting horizontal to true. Horizontal steppers are dynamic, so they automatically switch to vertical ones if the stepper component does not have enough space to properly display all steps. For the experience of mobile users, using the vertical stepper is generally the better idea.

html
<Stepper {active} length={2} on:complete={onComplete} horizontal={true}>
	<Step index={0}>
		<svelte:fragment slot="header">(header)</svelte:fragment>
		(content)
	</Step>
	<Step index={1} locked={true}>(content)</Step>
</Stepper>