Import
Anatomy
The NumberField component consists of multiple parts:NumberField.Root- The container that manages stateNumberField.Group- Groups the input and buttons togetherNumberField.Input- The text input elementNumberField.Increment- Button to increase the valueNumberField.Decrement- Button to decrease the valueNumberField.ScrubArea- Area for scrubbing to change valueNumberField.ScrubAreaCursor- Custom cursor for scrub area
Basic Usage
Key Features
- Controlled and uncontrolled modes
- Step increments with modifier keys (Shift for large, Alt for small)
- Mouse wheel support
- Scrub area for drag-to-change
- Min/max value constraints
- Number formatting with Intl.NumberFormat
- Currency, percentage, and unit formatting
- Customizable step values
- Out-of-range value support
Key Props
value
Type:number | null
The raw numeric value of the field. Use with onValueChange for controlled mode.
defaultValue
Type:number
The uncontrolled value when initially rendered.
min
Type:number
The minimum allowed value.
max
Type:number
The maximum allowed value.
step
Type:number | 'any'
Default: 1
Amount to increment and decrement.
smallStep
Type:number
Default: 0.1
The small step value when incrementing while Alt key is held.
largeStep
Type:number
Default: 10
The large step value when incrementing while Shift key is held.
format
Type:Intl.NumberFormatOptions
Options to format the input value.
allowWheelScrub
Type:boolean
Default: false
Whether to allow the user to scrub the value with the mouse wheel while focused.
snapOnStep
Type:boolean
Default: false
Whether the value should snap to the nearest step when incrementing or decrementing.
allowOutOfRange
Type:boolean
Default: false
When true, direct text entry may be outside the min/max range without clamping.
onValueChange
Type:(value: number | null, eventDetails: ChangeEventDetails) => void
Callback fired when the number value changes.
onValueCommitted
Type:(value: number | null, eventDetails: CommitEventDetails) => void
Callback fired when the value is committed (on blur, pointer release, or keyboard interaction).
Styling
- Tab Title
- Tab Title