Skip to content
+

Input

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

  • Feedback
  • Bundle size
Component demosComponents APIHooks API

Input API

Import

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

Props

Props of the native component are also available.

autoComplete

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.

Type:string


autoFocus

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

Type:bool


className

Class name applied to the root element.

Type:string


defaultValue

The default value. Use when the component is not controlled.

Type:any


disabled

If true, the component is disabled. The prop defaults to the value (false) inherited from the parent FormControl component.

Type:bool


endAdornment

Trailing adornment for this input.

Type:node


error

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.

Type:bool


id

The id of the input element.

Type:string


maxRows

Maximum number of rows to display when multiline option is set to true.

Type:number


minRows

Minimum number of rows to display when multiline option is set to true.

Type:number


multiline

If true, a textarea element is rendered.

Type:bool

Default:false


name

Name attribute of the input element.

Type:string


placeholder

The short hint displayed in the input before the user enters a value.

Type:string


readOnly

It prevents the user from changing the value of the field (not from interacting with the field).

Type:bool


required

If true, the input element is required. The prop defaults to the value (false) inherited from the parent FormControl component.

Type:bool


rows

Number of rows to display when multiline option is set to true.

Type:number


slotProps

The props used for each slot inside the Input.

Type:{ input?: func
| object, root?: func
| object }

Default:{}


slots

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.

Type:{ input?: elementType, root?: elementType, textarea?: elementType }

Default:{}


startAdornment

Leading adornment for this input.

Type:node


type

Type of the input element. It should be a valid HTML5 input type.

Type:'button'
| 'checkbox'
| 'color'
| 'date'
| 'datetime-local'
| 'email'
| 'file'
| 'hidden'
| 'image'
| 'month'
| 'number'
| 'password'
| 'radio'
| 'range'
| 'reset'
| 'search'
| 'submit'
| 'tel'
| 'text'
| 'time'
| 'url'
| 'week'

Default:'text'


value

The value of the input element, required for a controlled component.

Type:any



The ref is forwarded to the root element.

Slots

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

root

The component that renders the root.

Class name: .MuiInput-root

Default component: 'div'


input

The component that renders the input.

Class name: .MuiInput-input

Default component: 'input'


textarea

The component that renders the textarea.

Default component: 'textarea'


CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

.Mui-disabledSTATE

State class applied to the root element if disabled={true}.


.Mui-errorSTATE

State class applied to the root element if error={true}.


.Mui-focusedSTATE

State class applied to the root element if the component is focused.


.MuiInput-adornedEnd

Class name applied to the root element if endAdornment is provided.


.MuiInput-adornedStart

Class name applied to the root element if startAdornment is provided.


.MuiInput-formControl

Class name applied to the root element if the component is a descendant of FormControl.


.MuiInput-inputMultiline

Class name applied to the input element if multiline={true}.


.MuiInput-inputTypeSearch

Class name applied to the input element if type="search".


.MuiInput-multiline

Class name applied to the root element if multiline={true}.


Edit this page

Was this page helpful?


CheckboxNumber Input

Blog

Store