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.
Number fields let users enter, format, and adjust numeric values.
Props of the FormControl component are also available.
| Name | Type | Default | Description |
|---|---|---|---|
| allowOutOfRange | bool | false | If |
| allowWheelScrub | bool | false | If |
| autoFocus | bool | false | If |
| classes | object | - | Override or extend the styles applied to the component. See CSS classes API below for more details. |
| color | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | string | '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. |
| controlsPosition | 'end' | 'split' | 'stacked' | false | 'end' | The arrangement of the control buttons. Use |
| defaultValue | number | - | The initial numeric value for an uncontrolled field. Omit this prop to start with an empty field. Use |
| disabled | bool | false | If |
| endAdornment | node | - | Content displayed immediately after the input, such as a unit or a clear button. |
| error | bool | false | If |
| form | string | - | The |
| format | object | - | The |
| fullWidth | bool | false | If |
| helperText | node | - | The helper text content. |
| id | string | - | The |
| inputRef | func | { current?: object } | - | A ref to the visible |
| label | node | - | The label content. |
| largeStep | number | 10 | The amount to increment or decrement while holding the Shift key. |
| locale | Array<object | string> | object | string | - | The locale or locales used to format and parse the value. Defaults to the runtime's locale. |
| max | number | - | The upper bound for the numeric value. The increment button is disabled at or above this value. |
| min | number | - | The lower bound for the numeric value. The decrement button is disabled at or below this value. |
| name | string | - | Identifies the field when a form is submitted. The submitted value is the unformatted number. |
| onBlur | func | - | Callback fired when the input loses focus. |
| onFocus | func | - | Callback fired when the input receives focus. |
| onValueChange | func | - | Callback fired when the numeric value changes. Call Signature: function(value: number | null, eventDetails: object) => void
|
| onValueCommitted | func | - | Callback fired when the value is committed. Direct text entry commits on blur. Pointer presses on the stepper buttons and scrub interactions commit on pointer release. Keyboard and wheel changes commit immediately. Signature: function(value: number | null, eventDetails: object) => void
|
| placeholder | string | - | The short hint displayed in the input when it is empty. |
| readOnly | bool | false | If |
| render | element | func | - | Replaces the root element while preserving its styles and behavior. Accepts an element or a function that receives the root props and Base UI state. |
| required | bool | false | If |
| scrubAreaPosition | 'end' | 'start' | false | false | The placement of the drag handle used to adjust the value. Use |
| size | 'medium' | 'small' | string | 'medium' | The size of the component. |
| slotProps | { controls?: func | object, decrementButton?: func | object, formHelperText?: func | object, htmlInput?: func | object, incrementButton?: func | object, input?: func | object, inputLabel?: func | object, root?: func | object, scrubArea?: func | object, scrubAreaCursor?: func | object } | {} | The props used for each slot inside. |
| slots | { controls?: elementType, decrementButton?: elementType, formHelperText?: elementType, htmlInput?: elementType, incrementButton?: elementType, input?: elementType, inputLabel?: elementType, root?: elementType, scrubArea?: elementType, scrubAreaCursor?: elementType } | {} | The components used for each slot inside. |
| smallStep | number | 0.1 | The amount to increment or decrement while holding the Alt key (Option on macOS). |
| snapOnStep | bool | false | If |
| startAdornment | node | - | Content displayed immediately before the input, such as a currency symbol. |
| step | 'any' | number | 1 | The amount to increment or decrement with the buttons, arrow keys, mouse wheel, or scrub area. Set |
| sx | Array<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. |
| value | number | - | The controlled numeric value. Use |
| variant | 'filled' | 'outlined' | 'standard' | 'outlined' | The variant to use. |
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.
| Slot name | Class name | Default component | Description |
|---|---|---|---|
| controls | .MuiNumberField-controls | InputAdornment | The component that renders each group of stepper buttons. |
| decrementButton | .MuiNumberField-decrementButton | IconButton | The component that renders the decrement button. |
| formHelperText | .MuiNumberField-formHelperText | FormHelperText | The component that renders the helper text. |
| htmlInput | .MuiNumberField-htmlInput | 'input' | The component that renders the native input element. Use & .MuiNumberField-htmlInput in styleOverrides.root to style it. |
| incrementButton | .MuiNumberField-incrementButton | IconButton | The component that renders the increment button. |
| input | .MuiNumberField-input | OutlinedInput | The component that renders the Material input wrapper. |
| inputLabel | .MuiNumberField-inputLabel | InputLabel | The component that renders the input's label. |
| root | .MuiNumberField-root | FormControl | The component that renders the root. While scrubbing, the root has the MuiNumberField-scrubbing class. Use &.MuiNumberField-scrubbing in styleOverrides.root to style that state. |
| scrubArea | .MuiNumberField-scrubArea | 'span' | The component that renders the drag handle for adjusting the value. |
| scrubAreaCursor | .MuiNumberField-scrubAreaCursor | 'span' | The component that renders the custom cursor while dragging the scrub area. |
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
| Class name | Rule name | Description |
|---|---|---|
| .MuiNumberField-endAdornment | endAdornment | Styles applied to the wrapper around the end adornment content. |
| .MuiNumberField-startAdornment | startAdornment | Styles applied to the wrapper around the start adornment content. |
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverridesproperty in a custom theme.
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.