Stepper
Shows how far the user is through a fixed number of steps: a label, the current step over the total, and one segment per step. Steps are 1-based; value and max floor to whole numbers of at least 1, and value clamps to max.
Use for
- progress through a multi-step flow, such as step 2 of 3
- segments that jump back to an earlier step
Practices
| Guidance | Practice |
|---|---|
| Do | Pass localized label, countLabel and stepLabel. The defaults are English. |
| Do | Keep the current step in the flow's machine and pass it as value. See Multi-step flows (mosaic guides inspect controllers). |
API reference
Stepper
Renders a div with the text (cl-stepper-text, holding cl-stepper-label and cl-stepper-count) and the segments (cl-stepper-segments). Each segment is a cl-stepper-segment with data-state of complete, current or upcoming. Carries data-value and data-max.
Slot: cl-stepper
| Prop | Type | Description |
|---|---|---|
value | number | The current step, from 1. |
max | number | The number of steps. |
onValueChange | (value: number) => void | Makes each segment a button that calls this with its step. The current one gets aria-current='step'. Without it the segments are aria-hidden. |
label | string | Text before the count.Default: 'Step' |
countLabel | string | The count, with {step} and {total} filled in.Default: '{step} of {total}' |
stepLabel | string | Each segment button's accessible name, with {step} filled in.Default: 'Step {step}' |
Examples
Read-only
<Stepper value={1} max={3} />Navigable
<Stepper value={step} max={3} onValueChange={setStep} />