Number Field
A numeric input element with increment and decrement buttons, and a scrub area.
View as MarkdownUsage guidelines
- Form controls must have an accessible name: It can be created using a
<label>element or theFieldcomponent. See the forms guide.
Anatomy
Import the component and assemble its parts:
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
Groups all parts of the number field and manages its state.
Renders a <div> element.
namestring—
- Name
- Description
Identifies the field when a form is submitted.
- Type
string | undefined
defaultValuenumber—
- Name
- Description
The uncontrolled value of the field when it’s initially rendered.
To render a controlled number field, use the
valueprop instead.- Type
number | undefined
valuenumber | null—
- Name
- Description
The raw numeric value of the field.
- Type
number | null | undefined
onValueChangefunction—
- Name
- Description
Callback fired when the number value changes.
The
eventDetails.reasonindicates what triggered the change:'input-change'for parseable typing or programmatic text updates'input-clear'when the field becomes empty'input-blur'when formatting (and clamping, if enabled) occurs on blur'input-paste'for paste interactions'keyboard'for keyboard input'increment-press'/'decrement-press'for button presses on the increment and decrement controls'wheel'for wheel-based scrubbing'scrub'for scrub area drags
- Type
| (( value: number | null, eventDetails: NumberField.Root.ChangeEventDetails, ) => void) | undefined
onValueCommittedfunction—
- Name
- Description
Callback function that is fired when the value is committed. It runs later than
onValueChange, when:- The input is blurred after typing a value.
- The pointer is released after scrubbing or pressing the increment/decrement buttons.
It runs simultaneously with
onValueChangewhen interacting with the keyboard.Warning: This is a generic event not a change event.
- Type
| (( value: number | null, eventDetails: NumberField.Root.CommitEventDetails, ) => void) | undefined
allowOutOfRangebooleanfalse
- Name
- Description
When true, direct text entry may be outside the
min/maxrange without clamping, so native range underflow/overflow validation can occur. Step-based interactions (keyboard arrows, buttons, wheel, scrub) still clamp.- Type
boolean | undefined- Default
false
formstring—
- Name
- Description
Identifies the form that owns the hidden input. Useful when the number field is rendered outside the form.
- Type
string | undefined
localeIntl.LocalesArgument—
- Name
- Description
The locale of the input element. Defaults to the user’s runtime locale.
- Type
Intl.LocalesArgument | undefined
snapOnStepbooleanfalse
- Name
- Description
Whether the value should snap to the nearest step when incrementing or decrementing.
- Type
boolean | undefined- Default
false
stepnumber | 'any'1
- Name
- Description
Amount 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
minprop explicitly in conjunction with this prop. Specifystep="any"to always disable step validation.- Type
number | 'any' | undefined- Default
1
smallStepnumber0.1
- Name
- Description
The small step value of the input element when incrementing while the meta key is held. Snaps to multiples of this value.
- Type
number | undefined- Default
0.1
largeStepnumber10
- Name
- Description
The large step value of the input element when incrementing while the shift key is held. Snaps to multiples of this value.
- Type
number | undefined- Default
10
minnumber—
- Name
- Description
The minimum value of the input element.
- Type
number | undefined
maxnumber—
- Name
- Description
The maximum value of the input element.
- Type
number | undefined
allowWheelScrubbooleanfalse
- Name
- Description
Whether to allow the user to scrub the input value with the mouse wheel while focused and hovering over the input.
- Type
boolean | undefined- Default
false
formatIntl.NumberFormatOptions—
- Name
- Description
Options to format the input value.
- Type
Intl.NumberFormatOptions | undefined
disabledbooleanfalse
- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
readOnlybooleanfalse
- Name
- Description
Whether the user should be unable to change the field value.
- Type
boolean | undefined- Default
false
requiredbooleanfalse
- Name
- Description
Whether the user must enter a value before submitting a form.
- Type
boolean | undefined- Default
false
inputRefReact.Ref<HTMLInputElement>—
- Name
- Description
A ref to access the hidden input element.
- Type
React.Ref<HTMLInputElement> | undefined
idstring—
- Name
- Description
The id of the input element.
- Type
string | undefined
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: NumberField.Root.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: NumberField.Root.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: NumberField.Root.State, ) => ReactElement) | undefined
data-disabled
Present when the number field is disabled.
data-readonly
Present when the number field is readonly.
data-required
Present when the number field is required.
data-valid
Present when the number field is in valid state (when wrapped in Field.Root).
data-invalid
Present when the number field is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the number field’s value has changed (when wrapped in Field.Root).
data-touched
Present when the number field has been touched (when wrapped in Field.Root).
data-filled
Present when the number field is filled (when wrapped in Field.Root).
data-focused
Present when the number field is focused (when wrapped in Field.Root).
data-scrubbing
Present while scrubbing.
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the number field is disabled. | |
data-readonly | Present when the number field is readonly. | |
data-required | Present when the number field is required. | |
data-valid | Present when the number field is in valid state (when wrapped in Field.Root). | |
data-invalid | Present when the number field is in invalid state (when wrapped in Field.Root). | |
data-dirty | Present when the number field’s value has changed (when wrapped in Field.Root). | |
data-touched | Present when the number field has been touched (when wrapped in Field.Root). | |
data-filled | Present when the number field is filled (when wrapped in Field.Root). | |
data-focused | Present when the number field is focused (when wrapped in Field.Root). | |
data-scrubbing | Present while scrubbing. | |
NumberField.Root.StateHide
type NumberFieldRootState = {
/** The raw numeric value of the field. */
value: number | null;
/** The formatted string value presented in the input element. */
inputValue: string;
/** Whether the user must enter a value before submitting a form. */
required: boolean;
/** Whether the component should ignore user interaction. */
disabled: boolean;
/** Whether the user should be unable to change the field value. */
readOnly: boolean;
/** Whether the user is currently scrubbing the field. */
scrubbing: boolean;
/** Whether the field has been touched. */
touched: boolean;
/** Whether the field value has changed from its initial value. */
dirty: boolean;
/** Whether the field is valid. */
valid: boolean | null;
/** Whether the field has a value. */
filled: boolean;
/** Whether the field is focused. */
focused: boolean;
}NumberField.Root.ChangeEventReasonHide
type NumberFieldRootChangeEventReason =
| 'input-change'
| 'input-clear'
| 'input-blur'
| 'input-paste'
| 'keyboard'
| 'increment-press'
| 'decrement-press'
| 'wheel'
| 'scrub'
| 'none'NumberField.Root.ChangeEventDetailsHide
type NumberFieldRootChangeEventDetails = (
| { reason: 'input-change'; event: InputEvent | Event }
| { reason: 'input-clear'; event: InputEvent | Event | FocusEvent }
| { reason: 'input-blur'; event: FocusEvent }
| { reason: 'input-paste'; event: ClipboardEvent }
| { reason: 'keyboard'; event: KeyboardEvent }
| { reason: 'increment-press'; event: PointerEvent | MouseEvent | TouchEvent }
| { reason: 'decrement-press'; event: PointerEvent | MouseEvent | TouchEvent }
| { reason: 'wheel'; event: WheelEvent }
| { reason: 'scrub'; event: PointerEvent }
| { reason: 'none'; event: Event }
) & {
/** Cancels Base UI from handling the event. */
cancel: () => void;
/** Allows the event to propagate in cases where Base UI will stop the propagation. */
allowPropagation: () => void;
/** Indicates whether the event has been canceled. */
isCanceled: boolean;
/** Indicates whether the event is allowed to propagate. */
isPropagationAllowed: boolean;
/** The element that triggered the event, if applicable. */
trigger: Element | undefined;
direction?: -1 | 1;
}NumberField.Root.CommitEventReasonHide
type NumberFieldRootCommitEventReason =
| 'input-blur'
| 'input-clear'
| 'keyboard'
| 'increment-press'
| 'decrement-press'
| 'wheel'
| 'scrub'
| 'none'NumberField.Root.CommitEventDetailsHide
type NumberFieldRootCommitEventDetails =
| { reason: 'input-clear'; event: InputEvent | Event | FocusEvent }
| { reason: 'input-blur'; event: FocusEvent }
| { reason: 'keyboard'; event: KeyboardEvent }
| { reason: 'increment-press'; event: PointerEvent | MouseEvent | TouchEvent }
| { reason: 'decrement-press'; event: PointerEvent | MouseEvent | TouchEvent }
| { reason: 'wheel'; event: WheelEvent }
| { reason: 'scrub'; event: PointerEvent }
| { reason: 'none'; event: Event }ScrubArea
An interactive area where the user can click and drag to change the field value.
Renders a <span> element.
direction'horizontal' | 'vertical''horizontal'
- Name
- Description
Cursor movement direction in the scrub area.
- Type
'horizontal' | 'vertical' | undefined- Default
'horizontal'
pixelSensitivitynumber2
- Name
- Description
Determines how many pixels the cursor must move before the value changes. A higher value will make scrubbing less sensitive.
- Type
number | undefined- Default
2
teleportDistancenumber—
- Name
- Description
If specified, determines the distance that the cursor may move from the center of the scrub area before it will loop back around.
- Type
number | undefined
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: NumberField.ScrubArea.State, ) => string | undefined) | undefined
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: NumberField.ScrubArea.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: NumberField.ScrubArea.State, ) => ReactElement) | undefined
data-disabled
Present when the number field is disabled.
data-readonly
Present when the number field is readonly.
data-required
Present when the number field is required.
data-valid
Present when the number field is in valid state (when wrapped in Field.Root).
data-invalid
Present when the number field is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the number field’s value has changed (when wrapped in Field.Root).
data-touched
Present when the number field has been touched (when wrapped in Field.Root).
data-filled
Present when the number field is filled (when wrapped in Field.Root).
data-focused
Present when the number field is focused (when wrapped in Field.Root).
data-scrubbing
Present while scrubbing.
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the number field is disabled. | |
data-readonly | Present when the number field is readonly. | |
data-required | Present when the number field is required. | |
data-valid | Present when the number field is in valid state (when wrapped in Field.Root). | |
data-invalid | Present when the number field is in invalid state (when wrapped in Field.Root). | |
data-dirty | Present when the number field’s value has changed (when wrapped in Field.Root). | |
data-touched | Present when the number field has been touched (when wrapped in Field.Root). | |
data-filled | Present when the number field is filled (when wrapped in Field.Root). | |
data-focused | Present when the number field is focused (when wrapped in Field.Root). | |
data-scrubbing | Present while scrubbing. | |
NumberField.ScrubArea.StateHide
type NumberFieldScrubAreaState = {
/** The raw numeric value of the field. */
value: number | null;
/** The formatted string value presented in the input element. */
inputValue: string;
/** Whether the user must enter a value before submitting a form. */
required: boolean;
/** Whether the component should ignore user interaction. */
disabled: boolean;
/** Whether the user should be unable to change the field value. */
readOnly: boolean;
/** Whether the user is currently scrubbing the field. */
scrubbing: boolean;
/** Whether the field has been touched. */
touched: boolean;
/** Whether the field value has changed from its initial value. */
dirty: boolean;
/** Whether the field is valid. */
valid: boolean | null;
/** Whether the field has a value. */
filled: boolean;
/** Whether the field is focused. */
focused: boolean;
}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.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: NumberField.ScrubAreaCursor.State, ) => string | undefined) | undefined
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: NumberField.ScrubAreaCursor.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: NumberField.ScrubAreaCursor.State, ) => ReactElement) | undefined
data-disabled
Present when the number field is disabled.
data-readonly
Present when the number field is readonly.
data-required
Present when the number field is required.
data-valid
Present when the number field is in valid state (when wrapped in Field.Root).
data-invalid
Present when the number field is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the number field’s value has changed (when wrapped in Field.Root).
data-touched
Present when the number field has been touched (when wrapped in Field.Root).
data-filled
Present when the number field is filled (when wrapped in Field.Root).
data-focused
Present when the number field is focused (when wrapped in Field.Root).
data-scrubbing
Present while scrubbing.
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the number field is disabled. | |
data-readonly | Present when the number field is readonly. | |
data-required | Present when the number field is required. | |
data-valid | Present when the number field is in valid state (when wrapped in Field.Root). | |
data-invalid | Present when the number field is in invalid state (when wrapped in Field.Root). | |
data-dirty | Present when the number field’s value has changed (when wrapped in Field.Root). | |
data-touched | Present when the number field has been touched (when wrapped in Field.Root). | |
data-filled | Present when the number field is filled (when wrapped in Field.Root). | |
data-focused | Present when the number field is focused (when wrapped in Field.Root). | |
data-scrubbing | Present while scrubbing. | |
NumberField.ScrubAreaCursor.PropsHide
Re-Export of ScrubAreaCursor props as NumberFieldScrubAreaCursorProps
NumberField.ScrubAreaCursor.StateHide
type NumberFieldScrubAreaCursorState = {
/** The raw numeric value of the field. */
value: number | null;
/** The formatted string value presented in the input element. */
inputValue: string;
/** Whether the user must enter a value before submitting a form. */
required: boolean;
/** Whether the component should ignore user interaction. */
disabled: boolean;
/** Whether the user should be unable to change the field value. */
readOnly: boolean;
/** Whether the user is currently scrubbing the field. */
scrubbing: boolean;
/** Whether the field has been touched. */
touched: boolean;
/** Whether the field value has changed from its initial value. */
dirty: boolean;
/** Whether the field is valid. */
valid: boolean | null;
/** Whether the field has a value. */
filled: boolean;
/** Whether the field is focused. */
focused: boolean;
}Group
Groups the input with the increment and decrement buttons.
Renders a <div> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: NumberField.Group.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: NumberField.Group.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: NumberField.Group.State, ) => ReactElement) | undefined
data-disabled
Present when the number field is disabled.
data-readonly
Present when the number field is readonly.
data-required
Present when the number field is required.
data-valid
Present when the number field is in valid state (when wrapped in Field.Root).
data-invalid
Present when the number field is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the number field’s value has changed (when wrapped in Field.Root).
data-touched
Present when the number field has been touched (when wrapped in Field.Root).
data-filled
Present when the number field is filled (when wrapped in Field.Root).
data-focused
Present when the number field is focused (when wrapped in Field.Root).
data-scrubbing
Present while scrubbing.
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the number field is disabled. | |
data-readonly | Present when the number field is readonly. | |
data-required | Present when the number field is required. | |
data-valid | Present when the number field is in valid state (when wrapped in Field.Root). | |
data-invalid | Present when the number field is in invalid state (when wrapped in Field.Root). | |
data-dirty | Present when the number field’s value has changed (when wrapped in Field.Root). | |
data-touched | Present when the number field has been touched (when wrapped in Field.Root). | |
data-filled | Present when the number field is filled (when wrapped in Field.Root). | |
data-focused | Present when the number field is focused (when wrapped in Field.Root). | |
data-scrubbing | Present while scrubbing. | |
NumberField.Group.StateHide
type NumberFieldGroupState = {
/** The raw numeric value of the field. */
value: number | null;
/** The formatted string value presented in the input element. */
inputValue: string;
/** Whether the user must enter a value before submitting a form. */
required: boolean;
/** Whether the component should ignore user interaction. */
disabled: boolean;
/** Whether the user should be unable to change the field value. */
readOnly: boolean;
/** Whether the user is currently scrubbing the field. */
scrubbing: boolean;
/** Whether the field has been touched. */
touched: boolean;
/** Whether the field value has changed from its initial value. */
dirty: boolean;
/** Whether the field is valid. */
valid: boolean | null;
/** Whether the field has a value. */
filled: boolean;
/** Whether the field is focused. */
focused: boolean;
}Decrement
A stepper button that decreases the field value when clicked.
Renders an <button> element.
nativeButtonbooleantrue
- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (for example,<div>).- Type
boolean | undefined- Default
true
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: NumberField.Decrement.State, ) => string | undefined) | undefined
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: NumberField.Decrement.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: NumberField.Decrement.State, ) => ReactElement) | undefined
data-disabled
Present when the number field is disabled.
data-readonly
Present when the number field is readonly.
data-required
Present when the number field is required.
data-valid
Present when the number field is in valid state (when wrapped in Field.Root).
data-invalid
Present when the number field is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the number field’s value has changed (when wrapped in Field.Root).
data-touched
Present when the number field has been touched (when wrapped in Field.Root).
data-filled
Present when the number field is filled (when wrapped in Field.Root).
data-focused
Present when the number field is focused (when wrapped in Field.Root).
data-scrubbing
Present while scrubbing.
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the number field is disabled. | |
data-readonly | Present when the number field is readonly. | |
data-required | Present when the number field is required. | |
data-valid | Present when the number field is in valid state (when wrapped in Field.Root). | |
data-invalid | Present when the number field is in invalid state (when wrapped in Field.Root). | |
data-dirty | Present when the number field’s value has changed (when wrapped in Field.Root). | |
data-touched | Present when the number field has been touched (when wrapped in Field.Root). | |
data-filled | Present when the number field is filled (when wrapped in Field.Root). | |
data-focused | Present when the number field is focused (when wrapped in Field.Root). | |
data-scrubbing | Present while scrubbing. | |
NumberField.Decrement.StateHide
type NumberFieldDecrementState = {
/** The raw numeric value of the field. */
value: number | null;
/** The formatted string value presented in the input element. */
inputValue: string;
/** Whether the user must enter a value before submitting a form. */
required: boolean;
/** Whether the component should ignore user interaction. */
disabled: boolean;
/** Whether the user should be unable to change the field value. */
readOnly: boolean;
/** Whether the user is currently scrubbing the field. */
scrubbing: boolean;
/** Whether the field has been touched. */
touched: boolean;
/** Whether the field value has changed from its initial value. */
dirty: boolean;
/** Whether the field is valid. */
valid: boolean | null;
/** Whether the field has a value. */
filled: boolean;
/** Whether the field is focused. */
focused: boolean;
}Input
The native input control in the number field.
Renders an <input> element.
aria-roledescriptionstring'Number field'
- Description
A string value that provides a user-friendly name for the role of the input.
- Type
string | undefined- Default
'Number field'
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: NumberField.Input.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: NumberField.Input.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: NumberField.Input.State, ) => ReactElement) | undefined
data-disabled
Present when the number field is disabled.
data-readonly
Present when the number field is readonly.
data-required
Present when the number field is required.
data-valid
Present when the number field is in valid state (when wrapped in Field.Root).
data-invalid
Present when the number field is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the number field’s value has changed (when wrapped in Field.Root).
data-touched
Present when the number field has been touched (when wrapped in Field.Root).
data-filled
Present when the number field is filled (when wrapped in Field.Root).
data-focused
Present when the number field is focused (when wrapped in Field.Root).
data-scrubbing
Present while scrubbing.
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the number field is disabled. | |
data-readonly | Present when the number field is readonly. | |
data-required | Present when the number field is required. | |
data-valid | Present when the number field is in valid state (when wrapped in Field.Root). | |
data-invalid | Present when the number field is in invalid state (when wrapped in Field.Root). | |
data-dirty | Present when the number field’s value has changed (when wrapped in Field.Root). | |
data-touched | Present when the number field has been touched (when wrapped in Field.Root). | |
data-filled | Present when the number field is filled (when wrapped in Field.Root). | |
data-focused | Present when the number field is focused (when wrapped in Field.Root). | |
data-scrubbing | Present while scrubbing. | |
NumberField.Input.StateHide
type NumberFieldInputState = {
/** The raw numeric value of the field. */
value: number | null;
/** The formatted string value presented in the input element. */
inputValue: string;
/** Whether the user must enter a value before submitting a form. */
required: boolean;
/** Whether the component should ignore user interaction. */
disabled: boolean;
/** Whether the user should be unable to change the field value. */
readOnly: boolean;
/** Whether the user is currently scrubbing the field. */
scrubbing: boolean;
/** Whether the field has been touched. */
touched: boolean;
/** Whether the field value has changed from its initial value. */
dirty: boolean;
/** Whether the field is valid. */
valid: boolean | null;
/** Whether the field has a value. */
filled: boolean;
/** Whether the field is focused. */
focused: boolean;
}Increment
A stepper button that increases the field value when clicked.
Renders an <button> element.
nativeButtonbooleantrue
- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (for example,<div>).- Type
boolean | undefined- Default
true
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: NumberField.Increment.State, ) => string | undefined) | undefined
styleReact.CSSProperties | function—
- Name
- Type
| React.CSSProperties | (( state: NumberField.Increment.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: NumberField.Increment.State, ) => ReactElement) | undefined
data-disabled
Present when the number field is disabled.
data-readonly
Present when the number field is readonly.
data-required
Present when the number field is required.
data-valid
Present when the number field is in valid state (when wrapped in Field.Root).
data-invalid
Present when the number field is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the number field’s value has changed (when wrapped in Field.Root).
data-touched
Present when the number field has been touched (when wrapped in Field.Root).
data-filled
Present when the number field is filled (when wrapped in Field.Root).
data-focused
Present when the number field is focused (when wrapped in Field.Root).
data-scrubbing
Present while scrubbing.
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the number field is disabled. | |
data-readonly | Present when the number field is readonly. | |
data-required | Present when the number field is required. | |
data-valid | Present when the number field is in valid state (when wrapped in Field.Root). | |
data-invalid | Present when the number field is in invalid state (when wrapped in Field.Root). | |
data-dirty | Present when the number field’s value has changed (when wrapped in Field.Root). | |
data-touched | Present when the number field has been touched (when wrapped in Field.Root). | |
data-filled | Present when the number field is filled (when wrapped in Field.Root). | |
data-focused | Present when the number field is focused (when wrapped in Field.Root). | |
data-scrubbing | Present while scrubbing. | |
NumberField.Increment.StateHide
type NumberFieldIncrementState = {
/** The raw numeric value of the field. */
value: number | null;
/** The formatted string value presented in the input element. */
inputValue: string;
/** Whether the user must enter a value before submitting a form. */
required: boolean;
/** Whether the component should ignore user interaction. */
disabled: boolean;
/** Whether the user should be unable to change the field value. */
readOnly: boolean;
/** Whether the user is currently scrubbing the field. */
scrubbing: boolean;
/** Whether the field has been touched. */
touched: boolean;
/** Whether the field value has changed from its initial value. */
dirty: boolean;
/** Whether the field is valid. */
valid: boolean | null;
/** Whether the field has a value. */
filled: boolean;
/** Whether the field is focused. */
focused: boolean;
}