Quantity Stepper
ProNewA quantity control whose number slides in the direction of the change, stops at the stock limit, and turns its minus into Remove at one.
Installation
pnpm dlx shadcn@latest add @viewport/quantity-stepper
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| value* | number | — |
| onValueChange* | (value: number) => void | — |
| label* | stringWhat is being counted, e.g. "Quantity of Morning mug". It names the group for screen readers. | — |
| min | number | 1 |
| max | number | 99 |
| onRemove | () => voidAt the minimum, turn the minus into a remove button that calls this. | — |
| size | "sm" | "md" | "md" |
| disabled | boolean | — |
| className | string | — |
Accessibility
- A named group; the quantity is an output announced as it changes.
- Buttons are named and disable at the limits rather than doing nothing.
- Respects prefers-reduced-motion.