Reference
Stepper
Steps taken in order — an account, then billing, then a summary — with each step's state (done, current, an error) and the current step's block shown. bind: holds the current step, from 0; .linear keeps a step out of reach until the ones before it are passed.
Stepper(bind: State, linear: Bool) { … }
Since 6.2.0
linear
Your name and email.
A card, or an invoice each month.
Check it over, then start.
Step 1 of 3
Example
state step = 0
state billed = false
Stepper(bind: step) {
Stepper.Step("Account", done: step > 0) {
Text("Your name and email.")
Button("Next").primary { on click { step = 1 } }
}
Stepper.Step("Billing", done: billed) {
Text("A card, or an invoice each month.")
Button("Add a card").primary { on click { billed = true step = 2 } }
}
Stepper.Step("Confirm") {
Text("Check it over, then start.")
Button("Start the trial").success
}
}
Text("Step {step + 1} of 3").muted.sm
Linear: no skipping ahead
state step = 0
Stepper(bind: step).linear {
Stepper.Step("Upload") { Text("Choose the file") }
Stepper.Step("Review") { Text("Check the rows") }
}
A step with an error
state step = 1
Stepper(bind: step) {
Stepper.Step("Details", done: true) { Text("Saved") }
Stepper.Step("Payment", error: true) { Text("The card was declined.") }
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
bind: | State (required) | — | A Number state, the current step counted from 0: pressing a step's button writes it, and only that step's block shows |
linear: | Bool | false | A step after the current one cannot be pressed: its button is disabled. Written as a flag, |
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
.linear
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
children
Parts
The parts of Stepper are written under its name, inside it. Each is described here, with what it takes.
Stepper.Step
One step: its title in the list, its block shown while it is the current one.
Stepper.Step(_ title: String, done: Bool, error: Bool) { … }
| Prop | Type | Unset | Meaning |
|---|---|---|---|
title | String (positional) | — | Its title, on its button in the list and as its panel's name |
done: | Bool | false | Passed: drawn with a check while it is not the current step; |
error: | Bool | false | Something in it needs fixing: drawn as an error, before current or done; |
.done
.error
Drawn for it
What Stepper draws itself, by the class a stylesheet can select. They are not written.
| Part | Class | Meaning |
|---|---|---|
Stepper.List | — | The steps, in order. |
Stepper.Item | — | A step in the list. |
Renders with the class wf-stepper, stable across releases, so a stylesheet may target it.
Codes this can raise
These controls list the props' cases; the example below shows them written.