Number Field

A numeric input element with increment and decrement buttons, and a scrub area.

API reference

Import the component and place its parts the following way:

Anatomy
import { NumberField } from '@base-ui-components/react/number-field';

<NumberField.Root>
  <NumberField.ScrubArea>
    <NumberField.ScrubAreaCursor />
  </NumberField.ScrubArea>
  <NumberField.Group>
    <NumberField.Decrement />
    <NumberField.Input />
    <NumberField.Increment />
  </NumberField.Group>
</NumberField.Root>

Root

Groups all parts of the number field and manages its state. Renders a <div> element.

PropTypeDefault
allowWheelScrubbooleanfalse
autoFocusbooleanfalse
classNamestring | (state) => stringundefined
defaultValuenumberundefined
disabledbooleanfalse
formatIntl.NumberFormatOptionsundefined
idstringundefined
invalidbooleanfalse
largeStepnumber10
maxnumberundefined
minnumberundefined
namestringundefined
onValueChange(value, event) => voidundefined
readOnlybooleanfalse
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
requiredbooleanfalse
smallStepnumber0.1
stepnumberundefined
valuenumberundefined
Attribute
Description
data-dirty
data-disabled
data-invalid
data-readonly
data-required
data-scrubbing
data-touched
data-valid

ScrubArea

An interactive area where the user can click and drag to change the field value. Renders a <div> element.

PropTypeDefault
classNamestring | (state) => stringundefined
direction'horizontal' | 'vertical''horizontal'
pixelSensitivitynumber2
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
teleportDistancenumberundefined
Attribute
Description
data-dirty
data-disabled
data-invalid
data-readonly
data-required
data-scrubbing
data-touched
data-valid

ScrubAreaCursor

A custom element to display instead of the native cursor while using the scrub area. Renders a <span> element.

This component uses the Pointer Lock API, which may prompt the browser to display a related notification. It is disabled in Safari to avoid a layout shift that this notification causes there.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-invalid
data-readonly
data-required
data-scrubbing
data-touched
data-valid

Group

Groups the input with the increment and decrement buttons. Renders a <div> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-invalid
data-readonly
data-required
data-scrubbing
data-touched
data-valid

Decrement

A stepper button that decreases the field value when clicked. Renders an <button> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-invalid
data-readonly
data-required
data-scrubbing
data-touched
data-valid

Input

The native input control in the number field. Renders an <input> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-invalid
data-readonly
data-required
data-scrubbing
data-touched
data-valid

Increment

A stepper button that increases the field value when clicked. Renders an <button> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-dirty
data-disabled
data-invalid
data-readonly
data-required
data-scrubbing
data-touched
data-valid