Stepper
A number with − and + buttons either side, for small counts such as guests or copies.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
label | string | The label above it, and the spinbutton's accessible name. | |
value | number | bindable(0) | The number. Bind it with bind:value={name}. |
min | number | 0 | The smallest number; − is disabled there. |
max | number | 99 | The largest number; + is disabled there. |
step | number | 1 | How far one press or arrow key moves. Values land on steps counted from min. |
unit | string | | Written after the number, such as " kg"; also read by assistive technology. |
disabled | boolean | false | Cannot be changed or focused. |
States
| State | Looks like |
|---|---|
at a limit | The button that would pass min or max is grey and disabled. |
focused | The focus outline around the number. |
disabled | The whole part at 50% opacity. |
Accessibility
| role | spinbutton, with aria-valuenow, aria-valuemin, aria-valuemax and aria-valuetext (the number and its unit) |
| name | The label prop. The buttons are named "Decrease <label>" and "Increase <label>". |
| focus | One Tab stop, on the number. The − and + buttons are left out of the Tab order (tabindex -1), as the spinbutton pattern expects; they are for pointers and touch. |
| keyboard | ArrowUp and ArrowDown move one step, PageUp and PageDown ten steps, Home and End jump to min and max. |
Theme tokens
color.primary color.surface color.border color.raised color.muted color.ink space.1 space.2 radius.md radius.sm text.label text.body
Example
<Stepper label="Guests" min={1} max={8} bind:value={guests} />