Skip to content
+

Number Field

Number Field provides users with a numeric input, with buttons and a scrub area to increment or decrement its value.

useNumberFieldRoot API

Import

import { useNumberFieldRoot } from '@base_ui/react/NumberField';

Parameters

NameTypeDefaultDescription
allowWheelScrubbooleanfalse

Whether to allow the user to scrub the input value with the mouse wheel while focused and hovering over the input.

autoFocusbooleanfalse

If true, the input element is focused on mount.

defaultValuenumber-

The default value of the input element. Use when the component is not controlled.

disabledbooleanfalse

If true, the input element is disabled.

formatIntl.NumberFormatOptions-

Options to format the input value.

idstring-

The id of the input element.

invalidbooleanfalse

If true, the input element is invalid.

largeStepnumber10

The large step value of the input element when incrementing while the shift key is held. Snaps to multiples of this value.

maxnumber-

The maximum value of the input element.

minnumber-

The minimum value of the input element.

namestring-

The name of the input element.

onValueChange(value: number | null, event?: Event) => void-

Callback fired when the number value changes.

readOnlybooleanfalse

If true, the input element is read only.

requiredbooleanfalse

If true, the input element is required.

smallStepnumber0.1

The small step value of the input element when incrementing while the meta key is held. Snaps to multiples of this value.

stepnumber-

The step value of the input element when incrementing, decrementing, or scrubbing. It will snap to multiples of this value. When unspecified, decimal values are allowed, but the stepper buttons will increment or decrement by 1.

valuenumber | null-

The raw number value of the input element.

Return value

NameTypeDescription
getDecrementButtonProps(externalProps?: React.ComponentPropsWithRef<'button'>) => React.ComponentPropsWithRef<'button'>
getGroupProps(externalProps?: React.ComponentPropsWithRef<'div'>) => React.ComponentPropsWithRef<'div'>
getIncrementButtonProps(externalProps?: React.ComponentPropsWithRef<'button'>) => React.ComponentPropsWithRef<'button'>
getInputProps(externalProps?: React.ComponentPropsWithRef<'input'>) => React.ComponentPropsWithRef<'input'>
getScrubAreaCursorProps(externalProps?: React.ComponentPropsWithRef<'span'>) => React.ComponentPropsWithRef<'span'>
getScrubAreaProps(externalProps?: React.ComponentPropsWithRef<'span'>) => React.ComponentPropsWithRef<'span'>
inputRef((instance: HTMLInputElement | null) => void) | null
inputValuestring
isScrubbingboolean
scrubAreaCursorRefReact.RefObject<HTMLSpanElement>
scrubAreaRefReact.RefObject<HTMLSpanElement>
scrubHandleRefReact.RefObject<ScrubHandle | null>
valuenumber | null