Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Button Group examples · Forms

Quantity Picker Button Group for React

Two quantity pickers with minus and plus buttons around the count, the minus button disabled at zero.

Framework
UI library

The plus and minus control next to a product in a cart. ButtonGroupText shows the count between two icon buttons, starting at 1 in the first picker and Qty: 5 in the second. Minus turns off at zero so the count can't go negative.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How are the two quantities tracked?

Each picker has its own value, 1 and 5. Minus subtracts one, never below 0, and plus adds one with no upper limit.

When is minus disabled?

When that quantity is 0. The minus Button gets disabled from that check.

How are the icon buttons named?

Each has an aria-label, Decrease quantity or Increase quantity, and size="icon-sm". The icons have aria-hidden="true".

Is the new count announced?

Yes. The ButtonGroupText has aria-live="polite", so a screen reader reads the number after it changes.

Can people type a number?

Not here; the count is text. The Stepper Button Group puts an input between the buttons, and Number Input handles typing, limits and steps in one component.

How do I cap the quantity?

Stop plus at your stock limit and disable it there, the same way minus stops at 0.