Skip to content

Input

The Input component provides users with a field to enter and edit text.

Input API

Import

import Input from '@mui/base/Input';
// or
import { Input } from '@mui/base';
You can learn about the difference by reading this guide on minimizing bundle size.

Props

Props of the native component are also available.

NameTypeDefaultDescription
autoCompletestring
This prop helps users to fill forms faster, especially on mobile devices. The name can be confusing, as it's more like an autofill. You can learn more about it following the specification.
autoFocusbool
If true, the input element is focused during the first mount.
classNamestring
Class name applied to the root element.
defaultValueany
The default value. Use when the component is not controlled.
disabledbool
If true, the component is disabled. The prop defaults to the value (false) inherited from the parent FormControl component.
endAdornmentnode
Trailing adornment for this input.
errorbool
If true, the input will indicate an error by setting the aria-invalid attribute on the input and the Mui-error class on the root element. The prop defaults to the value (false) inherited from the parent FormControl component.
idstring
The id of the input element.
maxRowsnumber
Maximum number of rows to display when multiline option is set to true.
minRowsnumber
Minimum number of rows to display when multiline option is set to true.
multilineboolfalse
If true, a textarea element is rendered.
namestring
Name attribute of the input element.
placeholderstring
The short hint displayed in the input before the user enters a value.
readOnlybool
It prevents the user from changing the value of the field (not from interacting with the field).
requiredbool
If true, the input element is required. The prop defaults to the value (false) inherited from the parent FormControl component.
rowsnumber
Number of rows to display when multiline option is set to true.
slotProps{ input?: func
| object, root?: func
| object }
{}
The props used for each slot inside the Input.
slots{ input?: elementType, root?: elementType, textarea?: elementType }{}
The components used for each slot inside the InputBase. Either a string to use a HTML element or a component. See Slots API below for more details.
startAdornmentnode
Leading adornment for this input.
type'button'
| 'checkbox'
| 'color'
| 'date'
| 'datetime-local'
| 'email'
| 'file'
| 'hidden'
| 'image'
| 'month'
| 'number'
| 'password'
| 'radio'
| 'range'
| 'reset'
| 'search'
| 'submit'
| 'tel'
| 'text'
| 'time'
| 'url'
| 'week'
'text'
Type of the input element. It should be a valid HTML5 input type.
valueany
The value of the input element, required for a controlled component.

The ref is forwarded to the root element.

Slots

To learn how to customize the slot, check out the Overriding component structure guide.

NameDefault classDefault HTML tagDescription
root.MuiInput-root'div'The component that renders the root.
input.MuiInput-input'input'The component that renders the input.
textarea'textarea'The component that renders the textarea.

You can override the style of the component using one of these customization options:

CSS classes

These class names are useful for styling with CSS. They are applied to the root slot when specific states are triggered.

Global classDescription
.Mui-disabled
STATE
State class applied to the root element if disabled={true}.
.Mui-error
STATE
State class applied to the root element if error={true}.
.Mui-focused
STATE
State class applied to the root element if the component is focused.
.MuiInput-adornedEndClass name applied to the root element if endAdornment is provided.
.MuiInput-adornedStartClass name applied to the root element if startAdornment is provided.
.MuiInput-formControlClass name applied to the root element if the component is a descendant of FormControl.
.MuiInput-inputMultilineClass name applied to the input element if multiline={true}.
.MuiInput-inputTypeSearchClass name applied to the input element if type="search".
.MuiInput-multilineClass name applied to the root element if multiline={true}.