Stepper
Divide and present content in sequenced steps.
import { Stepper, Step } from '@brainandbones/skeleton';
Examples
1
Step 1 - Get Started!
This example will teach you how to use the Stepper component. Tap next to proceed forward.
2
Step 2
🔒
Step 3
4
Step 4
5
Step 5
Usage
To begin, create a writable that will store your active step value. This should always be set to 0
(zero).
import type { Writable } from "svelte/store";
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.
<Stepper {active} length={5} 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.
const onComplete: any = () => { /* handle the event */ }
Properties
Stepper
Prop | Type | Default | Required | Description |
---|---|---|---|---|
active | Writable | writable(0) | ✓ | Provide a writable which stores the actively selected step state. |
length | number | 0 | ✓ | Provide a count of the total number of Steps (children). |
duration | number | 200 | - | Set the Svelte transition duration. |
color | string | text-white | - | Provide classes to set the numeral text color. |
background | string | bg-accent-500 text-white | - | Provide classes to set the timeline background color. |
Prop | Type | Default | Description |
---|---|---|---|
buttonBack | string | btn-ghost | Provide Button element classes. |
buttonNext | string | btn-filled | Provide Button element classes. |
buttonComplete | string | btn-filled-primary | Provide Button element classes. |
Step
Prop | Type | Default | Required | Description |
---|---|---|---|---|
index | number | - | ✓ | Indicates the step index value. Should start with 0 (zero) |
locked | boolean | false | - | When enabled, a lock icon appears and the Next button is disabled. This prevents progress. |
Slots
Stepper
Name | Description |
---|---|
default | Accepts a set of steps to display. |
Step
Name | Description |
---|---|
default | Provide the content for the step. |
header | Override the auto-generated heading with your own value. Typically a step title. |
Events
Stepper
Prop | Description |
---|---|
complete | Triggers when the final step's Complete button is pressed. |