Number Field
Displays a number field built on the Base UI Number Field primitive.
Installation
Bash
Usage
Features
- ScrubArea with Pointer Lock: The
NumberFieldScrubAreacomponent enables drag-to-adjust functionality using Pointer Lock API. Drag horizontally to increase or decrease the value. Note: Pointer Lock is not available in Safari. - Number Formatting: Use the
formatprop (acceptsIntl.NumberFormatOptions) to customize how numbers are displayed in the input field. - Stepper Buttons: Increment and decrement buttons for precise value adjustments.
- Step Values: Configure
stepfor regular increments,smallStepfor fine adjustments (e.g., mouse scroll), andlargeStepfor large jumps (e.g., shift+scroll).
Examples
Currency
format takes Intl.NumberFormatOptions; largeStep applies while
holding Shift. Drag the label to scrub the value.
Quantity
A compact stepper clamped with min and max.
API reference
Number Field is a Base UI exclusive — shadcn/ui has no equivalent component. The parts compose explicitly, as in the demo above.
NumberField
Extends the Base UI Number Field Root — all its props apply.
| Prop | Type | Default |
|---|---|---|
value / defaultValue | number | null | — |
onValueChange | (value: number | null) => void | — |
min / max | number | — |
step | number | 1 |
largeStep | number — step while holding Shift | 10 |
format | Intl.NumberFormatOptions | — |
disabled | boolean | false |
NumberFieldGroup, NumberFieldInput, NumberFieldIncrement, NumberFieldDecrement
Styled Base UI parts: the group draws the bordered container, the input holds the formatted value, and the stepper buttons come with their plus/minus icons built in (hold to repeat).
NumberFieldScrubArea
Wraps a label to make it scrubbable — dragging it adjusts the value with a pointer-lock cursor.