Skip to contentSkip to content

NumberField API

API reference docs for the React NumberField component. Learn about the props, CSS, and other APIs of this exported module.

Demos

Import

import NumberField from '@mui/material/NumberField';
// or
import { NumberField } from '@mui/material';

Learn about the difference by reading this guide on minimizing bundle size.

Props

Props of the FormControl component are also available.

NameTypeDefaultDescription
allowOutOfRangeboolfalse

If true, the number input element will allow values outside the specified range.

allowWheelScrubboolfalse

If true, the number input element will respond to wheel scrub gestures.

autoFocusboolfalse

If true, the input element is focused during the first mount.

classesobject-

Override or extend the styles applied to the component.

See CSS classes API below for more details.

color'error'
| 'info'
| 'primary'
| 'secondary'
| 'success'
| 'warning'
'primary'

The color of the component. It supports both default and custom theme colors, which can be added as shown in the palette customization guide.

defaultValuenumber-

The default value of the number input element.

disabledboolfalse

If true, the component is disabled.

errorboolfalse

If true, the label is displayed in an error state.

formstring-

Identifies the form that owns the input element.

format{ compactDisplay?: 'long'
| 'short', currency?: string, currencyDisplay?: 'code'
| 'name'
| 'narrowSymbol'
| 'symbol', currencySign?: 'accounting'
| 'standard', localeMatcher?: 'best fit'
| 'lookup', maximumFractionDigits?: number, maximumSignificantDigits?: number, minimumFractionDigits?: number, minimumIntegerDigits?: number, minimumSignificantDigits?: number, notation?: 'compact'
| 'engineering'
| 'scientific'
| 'standard', numberingSystem?: string, signDisplay?: 'always'
| 'auto'
| 'exceptZero'
| 'never', style?: 'currency'
| 'decimal'
| 'percent'
| 'unit', unit?: string, unitDisplay?: 'long'
| 'narrow'
| 'short', useGrouping?: bool }
-

Options to format the input value.
See MDN - Intl.

fullWidthboolfalse

If true, the input will take up the full width of its container.

helperTextnode-

The helper text content.

idstring-

The id of the input element.

inputReffunc
| { current?: object }
-

The ref of the input element.

labelnode-

The label content.

largeStepnumber-

The large step value for the number input element.

localeArray<{ baseName: string, calendar?: string, caseFirst?: 'false'
| 'lower'
| 'upper', collation?: string, hourCycle?: 'h11'
| 'h12'
| 'h23'
| 'h24', language: string, maximize: func, minimize: func, numberingSystem?: string, numeric?: bool, region?: string, script?: string, toString: func }
| string>
| { baseName: string, calendar?: string, caseFirst?: 'false'
| 'lower'
| 'upper', collation?: string, hourCycle?: 'h11'
| 'h12'
| 'h23'
| 'h24', language: string, maximize: func, minimize: func, numberingSystem?: string, numeric?: bool, region?: string, script?: string, toString: func }
| string
-

The locale used for number formatting and parsing.
See MDN - Intl Number Format.

maxnumber-

The maximum value allowed for the number input element.

minnumber-

The minimum value allowed for the number input element.

namestring-

Name attribute of the input element.

onBlurfunc-

The blur event handler of the input element.

onFocusfunc-

The focus event handler of the input element.

onValueChangefunc-

The change event handler of the number input element.

onValueCommittedfunc-

The committed value event handler of the number input element.

readOnlyboolfalse

If true, the input element is read-only.

requiredboolfalse

If true, the label is displayed as required and the input element is required.

size'small'
| 'medium'
'medium'

The size of the component.

slotProps{ formHelperText?: func
| object, htmlInput?: func
| object, input?: func
| object, inputLabel?: func
| object, root?: func
| object }
{}

The props used for each slot inside.

slots{ formHelperText?: elementType, htmlInput?: elementType, input?: elementType, inputLabel?: elementType, root?: elementType }{}

The components used for each slot inside.

smallStepnumber-

The small step value for the number input element.

snapOnStepboolfalse

If true, the number input element will snap to the nearest step value.

step'any'
| number
-

The step attribute of the number input element.

sxArray<func
| object
| bool>
| func
| object
-

The system prop that allows defining system overrides as well as additional CSS styles.

See the `sx` page for more details.

valuenumber-

The value of the number input element.

variant'filled'
| 'outlined'
| 'standard'
'outlined'

The variant to use.

The ref is forwarded to the root element.

Inheritance

While not explicitly documented above, the props of the FormControl component are also available in NumberField. You can take advantage of this to target nested components.

Theme default props

You can use MuiNumberField to change the default props of this component with the theme.

Slots

Slot nameClass nameDefault componentDescription
formHelperTextFormHelperTextThe component that renders the helper text.
inputOutlinedInputThe component that renders the input.
inputLabelInputLabelThe component that renders the input's label.
htmlInput'input'The html input element.
root.MuiNumberField-rootFormControlThe component that renders the root

Source code

If you did not find the information in this page, consider having a look at the implementation of the component for more detail.