Jone

Number Field

A high-quality, unstyled React number field component with increment and decrement buttons, and a scrub area.

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

Usage guidelines

  • Form controls must have an accessible name: It can be created using a <label> element or the Field component. See the forms guide.

Anatomy

Import the component and assemble its parts:

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

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

API reference

Root

NameTypeDefaultDescription
idOptionalstring | undefinedThe id of the input element.
minOptionalnumber | undefinedThe minimum value of the input element.
maxOptionalnumber | undefinedThe maximum value of the input element.
allowOutOfRangeOptionalboolean | undefinedfalseWhen true, direct text entry may be outside the `min`/`max` range without clamping, so native range underflow/overflow validation can occur. Step-based interactions (keyboard arrows, buttons, wheel, scrub) still clamp.
smallStepOptionalnumber | undefined0.1The small step value of the input element when incrementing while the meta key is held. Snaps to multiples of this value.
stepOptionalnumber | 'any' | undefined1Amount to increment and decrement with the buttons and arrow keys, or to scrub with pointer movement in the scrub area. To always enable step validation on form submission, specify the `min` prop explicitly in conjunction with this prop. Specify `step="any"` to always disable step validation.
largeStepOptionalnumber | undefined10The large step value of the input element when incrementing while the shift key is held. Snaps to multiples of this value.
requiredOptionalboolean | undefinedfalseWhether the user must enter a value before submitting a form.
disabledOptionalboolean | undefinedfalseWhether the component should ignore user interaction.
readOnlyOptionalboolean | undefinedfalseWhether the user should be unable to change the field value.
nameOptionalstring | undefinedIdentifies the field when a form is submitted.
valueOptionalnumber | null | undefinedThe raw numeric value of the field.
defaultValueOptionalnumber | undefinedThe uncontrolled value of the field when it's initially rendered. To render a controlled number field, use the `value` prop instead.
allowWheelScrubOptionalboolean | undefinedfalseWhether to allow the user to scrub the input value with the mouse wheel while focused and hovering over the input.
snapOnStepOptionalboolean | undefinedfalseWhether the value should snap to the nearest step when incrementing or decrementing.
formatOptionalIntl.NumberFormatOptions | undefinedOptions to format the input value.
localeOptionalIntl.LocalesArgument | undefinedThe locale of the input element. Defaults to the user's runtime locale.
inputRefOptionalReact.Ref<HTMLInputElement> | undefinedA ref to access the hidden input element.

ScrubArea

NameTypeDefaultDescription
directionOptional'horizontal' | 'vertical' | undefinedhorizontalCursor movement direction in the scrub area.
pixelSensitivityOptionalnumber | undefined2Determines how many pixels the cursor must move before the value changes. A higher value will make scrubbing less sensitive.
teleportDistanceOptionalnumber | undefinedIf specified, determines the distance that the cursor may move from the center of the scrub area before it will loop back around.

On this page