Quantity Stepper
betaA − count + pill whose number rolls like an odometer, whose pressed button flashes, and whose running total updates from a unit price.
- Forms
- 1 file
- 1 npm package
- Accessibility notes
Loading the example…
pnpm dlx @dowel-ui/cli add quantity-steppernpm packages installed: class-variance-authority.
import { QuantityStepper } from "@/components/ui/quantity-stepper";Default
Demo
Count Only
<QuantityStepper>
| Prop | Type | Default |
|---|---|---|
currencyISO currency for the total. | string | "USD" |
decrementLabelAccessible name of the − button. | string | "Decrease quantity" |
defaultValueInitial count when uncontrolled. | number | 1 |
disabled | boolean | false |
formatTotalWrites the total yourself, instead of the currency format. | (total: number) => string | — |
incrementLabelAccessible name of the + button. | string | "Increase quantity" |
localeLocale for the total. | string | "en-US" |
maxHighest count. | number | 99 |
minLowest count. | number | 0 |
onValueChangeCalled with the new count. | (value: number) => void | — |
size | "sm" | "md" | "lg" | "md" |
totalLabelWord before the total. | string | "Total" |
unitPricePrice of one item. Leave unset to hide the total. | number | — |
valueControlled count. | number | — |
Plus every attribute of <div> except defaultValue, onChange, children.
A role="group" named "Quantity" (or aria-label) holding two native buttons, "Decrease quantity" and "Increase quantity", each disabled at its bound and with a visible focus ring. The count lives in an <output> polite, atomic live region whose hidden text is the plain number, so each change is announced once; the rolling digits are aria-hidden. The total is plain text, read in place. Under reduced motion the number and total change without rolling or flashing.
10/10
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — passes
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — passes
- No fixed widths — passes