Quantity Stepper

Quantity Stepper is a copy-paste React component that stops accidental bulk order before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/quantity-stepper
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsAccidental bulk order

Was this component page useful?

How do I install Quantity Stepper?

pnpm dlx shadcn@latest add @bollard/quantity-stepper

The files land in your project. They're yours to edit.

How do I use Quantity Stepper in React?

quantity-stepper-usage.tsx
import { QuantityStepper } from "@/components/ui/quantity-stepper"

<QuantityStepper label="Coffee beans, 250 g" value={cart} onValueChange={setCart} typical={2} max={500} stock={250} />

What input mistakes does Quantity Stepper catch?

  • Typed jumps far above the typical quantity (100 when people order 2)
  • Values over max or stock, clamped with a reason
  • Quantities that aren't a whole pack (step)
  • Scroll-wheel changes while scrolling the page

What props does Quantity Stepper accept?

QuantityStepper props
PropTypeDefault
label

Visible label.

string"Quantity"
value

Controlled quantity.

number—
defaultValue

Initial quantity when uncontrolled.

number—
onValueChange

Called with every committed quantity. Suspicious typed jumps wait for confirmation first.

(value: number) => void—
min

Lowest allowed quantity.

number1
max

Highest allowed quantity.

number99
stock

Units available; the effective maximum is the lower of `max` and `stock`.

number—
typical

What a typical order looks like. Typed values far above it ask for confirmation.

number—
step

Units per step (a pack size). Typed values snap to whole steps counted from `min`.

number1
soldOutMessage

Text shown when stock is below the minimum.

string—
decreaseLabel

Accessible labels of the − and + buttons.

string—
increaseLabel

Accessible label for the plus button.

string—
messages

Override any other user-visible string (see `QUANTITY_MESSAGES`).

Partial<QuantityMessages>—

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

How is Quantity Stepper accessible?

  • Visible label; the input is a spinbutton with min, max and now values, described by a hint
  • Enter commits a typed value
  • +/- buttons have aria-labels and aria-controls, and are skipped in tab order

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Validate quantity against live stock and order limits on the server.

  • "Suspicious" is relative to your typical prop
  • Stock shown is what you pass; it may be stale
  • Doesn't reserve stock

What expensive mistakes does Quantity Stepper stop?

Accidental bulk order

Also known as

quantity · stepper · qty · add to cart · cart · plus minus · number input · stock

Field type

What dependencies does Quantity Stepper require?

Quantity Stepper facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameQuantity Stepper
Registry identifier@bollard/quantity-stepper
Install commandnpx shadcn@latest add @bollard/quantity-stepper
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Quantity Stepper

How does Quantity Stepper prevent financial transaction errors?

Quantity Stepper prevents accidental bulk order. Blocks Typed jumps far above the typical quantity (100 when people order 2), Values over max or stock, clamped with a reason, Quantities that aren't a whole pack (step), Scroll-wheel changes while scrolling the page before processing. Limitation: apply idempotency keys for quantity-stepper.

How do I install quantity-stepper with shadcn?

Run `npx shadcn@latest add @bollard/quantity-stepper`. Sources added: registry/default/quantity-stepper/quantity-stepper.tsx. Package requirements: lucide-react.

What props customize Quantity Stepper?

Quantity Stepper accepts `label`, `value`, `defaultValue`, `onValueChange`, `min`. Configures quantity, stepper, qty behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of quantity-stepper?

"Suspicious" is relative to your typical prop. Stock shown is what you pass; it may be stale. Doesn't reserve stock Server requirement: Validate quantity against live stock and order limits on the server.

How does Quantity Stepper meet accessibility guidelines?

Visible label; the input is a spinbutton with min, max and now values, described by a hint. Enter commits a typed value. +/- buttons have aria-labels and aria-controls, and are skipped in tab order. Minimizes errors: quantity typo 100 instead of 10, scroll changes number input.

Which components pair with Quantity Stepper?