Duolith docs

Stepper

A number with − and + buttons either side, for small counts such as guests or copies.

Stability: experimental

Props

PropTypeDefaultMeans
labelstringThe label above it, and the spinbutton's accessible name.
valuenumberbindable(0)The number. Bind it with bind:value={name}.
minnumber0The smallest number; − is disabled there.
maxnumber99The largest number; + is disabled there.
stepnumber1How far one press or arrow key moves. Values land on steps counted from min.
unitstringWritten after the number, such as " kg"; also read by assistive technology.
disabledbooleanfalseCannot be changed or focused.

States

StateLooks like
at a limitThe button that would pass min or max is grey and disabled.
focusedThe focus outline around the number.
disabledThe whole part at 50% opacity.

Accessibility

rolespinbutton, with aria-valuenow, aria-valuemin, aria-valuemax and aria-valuetext (the number and its unit)
nameThe label prop. The buttons are named "Decrease <label>" and "Increase <label>".
focusOne 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.
keyboardArrowUp 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} />