Skip to content
Hazine

Number Input with Stepper Buttons

Numeric field with a minus and a plus button that step by a set amount and speed up while held. Use for small bounded quantities such as seats, nights or cart lines.

How it differs. Explicit decrement and increment buttons on either side of a centred, typeable value, with accelerating press and hold repeat and buttons that disable at the bounds.

Install

pnpm dlx shadcn@latest add @hazine/number-input-stepper-buttons

Adds 1 file, 1 Hazine item (@hazine/use-controllable-state), and 2 packages (lucide-react, class-variance-authority).

First time? Add the registry to components.json
{
  "registries": {
    "@hazine": "https://api.hazine.dev/r/{name}.json"
  }
}

Needed once per project. Items resolve each other through the @hazine namespace.

Props11

value
number
defaultValue
number
onValueChange
(value: number) => void
min
number = Number.NEGATIVE_INFINITY
max
number = Number.POSITIVE_INFINITY
step
number = 1
largeStep
number = step * 10
Amount for Page Up and Page Down. Defaults to ten steps.
locale
string = "en-US"
BCP 47 tag. Sets the group and decimal separators the field shows and accepts. Digits are always Latin.
decrementLabel
string = "Decrease"
incrementLabel
string = "Increase"
formatValueText
(value: number) => string
Spoken form of the value for assistive technology, for example "12 seats".

Also accepts every prop of Omit< React.ComponentProps<"input">, | "value" | "defaultValue" | "onChange" | "type" | "role" | "min" | "max" | "step" > and VariantProps<typeof numberInputStepperButtonsVariants>.

Accessibility

Keyboard
Keyboard support for Number Input with Stepper Buttons
KeyEffect
Digits and separatorsEdit the value as text. It is clamped to the bounds when committed
Arrow Up, Arrow DownIncrease or decrease by one step, starting from typed text when there is any
Page Up, Page DownIncrease or decrease by the large step
Home, EndSet the minimum or maximum, when one is defined. Otherwise the caret moves as usual
Shift, Alt, Control or Command with any key aboveLeft to the browser, so text selection and shortcuts keep working
EnterCommit typed text, then submit the form as usual
EscapeDiscard typed text
TabCommit typed text and leave the field. The step buttons are skipped
Screen reader

Text input with role spinbutton and value attributes, chosen over type number because the native control changes on scroll and cannot show grouped digits or carry value text. Step buttons are named and outside the tab order.

Reduced motion
No motion. Colour transitions only.
Checked
Not checked yet. Automated results appear here once CI has run.

Dependencies3

  • @hazine/use-controllable-state
  • lucide-react
  • class-variance-authority

Filled chips are registry items the CLI adds for you. Outlined chips are npm packages.

Tokens shipped0

None. The item is styled by the tokens your theme already has.

More in Text Inputs