Number Field

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

API reference

Import the component and assemble its parts:

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
name

string

undefined

defaultValue

number

undefined

value

number

undefined

onValueChange

(value, event) => void

undefined

step

number

1;

smallStep

number

0.1

largeStep

number

10

min

number

undefined

max

number

undefined

allowWheelScrub

boolean

false

format

Intl.NumberFormatOptions

undefined

autoFocus

boolean

false

disabled

boolean

false

readOnly

boolean

false

required

boolean

false

invalid

boolean

false

id

string

undefined

className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched
data-scrubbing

ScrubArea

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

PropTypeDefault
direction

'horizontal' | 'vertical'

'horizontal'

pixelSensitivity

number

2

teleportDistance

number

undefined

className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched
data-scrubbing

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
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched
data-scrubbing

Group

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

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched
data-scrubbing

Decrement

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

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched
data-scrubbing

Input

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

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched
data-scrubbing

Increment

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

PropTypeDefault
className

string | (state) => string

undefined

render

| React.ReactElement
| (props, state) => React.ReactElement

undefined

Attribute
Description
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched
data-scrubbing