Skip to content

Number field

A number input with steppers on Base UI NumberField.

With a label

Minimum and maximum

Step and format

Disabled

Installation

npx shadcn@latest add @khaeli/number-field

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

Registry items
npm packages
  • @base-ui/react ^1.7.0
  • @keyline-icons/react ^2.2.0

Keyboard

ArrowUpArrowDown
Raise and lower the value by one step.
Shift + ArrowUpShift + ArrowDown
Raise and lower it by ten steps.
Alt + ArrowUpAlt + ArrowDown
Raise and lower it by a tenth of a step.
HomeEnd
Jump to min and to max, when they are set.
Tab
Moves focus to the input and then past the field: the two steppers are for pointers and are not in the tab order.

Accessible name

  • id goes to the input, so a @khaeli/label with htmlFor names it. Without a visible label, pass aria-label.
  • The steppers are named Decrease and Increase.
  • A hint such as the allowed range is tied to the input with aria-describedby.
  • At a limit a polite live region says where the value stopped ("4, maximum"). A typed number outside the range is corrected when focus leaves, and the region says what it became ("Set to 4, the maximum").

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/number-field.json