Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Button Group examples · Advanced

Stepper Button Group for React

Two steppers with a number field between down and up buttons, stepping a quantity by 1 and a price by 10.

Framework
UI library

A number field with step buttons on both sides. The quantity steps by 1 and the price by 10, neither going below 0, and both can be typed into directly. The Input sits inside the ButtonGroup, so it shares the buttons' borders.

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 values tracked?

Each stepper keeps a number, 1 and 100. Down subtracts the step and stops at 0, up adds it, and typing in the field stores the typed number.

How are the chevron buttons named?

Each has an aria-label, such as Decrease quantity or Increase price, and size="icon-md". The fields have aria-labels too, Quantity and Price.

What happens if someone types a negative number?

It's stored as typed; only the buttons stop at 0. Add min to the input and clamp the typed value if negatives aren't allowed.

What happens when the field is cleared?

An empty field is stored as 0, since the demo converts the text to a number. Keep the raw text if you need to tell empty from 0.

Is there a component for this?

Yes. Number Input handles typing, limits, steps and keyboard increments in one component.

How wide is the field?

w-20 for the quantity and w-24 for the price, with text-center so the number sits between the buttons.