OutlinedInput API
Demos
For examples and details on the usage of this React component, visit the component demo pages:
Import
import OutlinedInput from '@mui/material/OutlinedInput';
// or
import { OutlinedInput } from '@mui/material';
Props of the InputBase component are also available.
Name | Type | Default | Description |
---|---|---|---|
autoComplete | string | 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. | |
autoFocus | bool | If | |
classes | object | Override or extend the styles applied to the component. See CSS API below for more details. | |
color | 'primary' | 'secondary' | string | The color of the component. It supports both default and custom theme colors, which can be added as shown in the palette customization guide. The prop defaults to the value ( | |
components | { Input?: elementType, Root?: elementType } | {} | The components used for each slot inside. |
defaultValue | any | The default value. Use when the component is not controlled. | |
disabled | bool | If | |
endAdornment | node | End | |
error | bool | If | |
fullWidth | bool | false | If |
id | string | The id of the | |
inputComponent | elementType | 'input' | The component used for the |
inputProps | object | {} | Attributes applied to the |
inputRef | ref | Pass a ref to the | |
label | node | The label of the | |
margin | 'dense' | 'none' | If | |
maxRows | number | string | Maximum number of rows to display when multiline option is set to true. | |
minRows | number | string | Minimum number of rows to display when multiline option is set to true. | |
multiline | bool | false | If |
name | string | Name attribute of the | |
notched | bool | If | |
onChange | func | Callback fired when the value is changed. Signature: function(event: React.ChangeEvent
| |
placeholder | string | The short hint displayed in the | |
readOnly | bool | It prevents the user from changing the value of the field (not from interacting with the field). | |
required | bool | If | |
rows | number | string | Number of rows to display when multiline option is set to true. | |
slots | { input?: elementType, root?: elementType } | {} | The components used for each slot inside. |
startAdornment | node | Start | |
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. | |
type | string | 'text' | Type of the |
value | any | The value of the |
ref
is forwarded to the root element.Inheritance
While not explicitly documented above, the props of the InputBase component are also available in OutlinedInput. You can take advantage of this to target nested components.
Theme default props
You can use MuiOutlinedInput
to change the default props of this component with the theme.
The following class names are useful for styling with CSS (the state classes are marked).
To learn more, visit the component customization page.
Global class | Rule name | Description |
---|---|---|
.MuiOutlinedInput-root | root | Styles applied to the root element. |
.MuiOutlinedInput-colorSecondary | colorSecondary | Styles applied to the root element if the color is secondary. |
.Mui-focused | focused | Styles applied to the root element if the component is focused. |
.Mui-disabled | disabled | Styles applied to the root element if disabled={true} . |
.MuiOutlinedInput-adornedStart | adornedStart | Styles applied to the root element if startAdornment is provided. |
.MuiOutlinedInput-adornedEnd | adornedEnd | Styles applied to the root element if endAdornment is provided. |
.Mui-error | error | State class applied to the root element if error={true} . |
.MuiOutlinedInput-sizeSmall | sizeSmall | Styles applied to the input element if size="small" . |
.MuiOutlinedInput-multiline | multiline | Styles applied to the root element if multiline={true} . |
.MuiOutlinedInput-notchedOutline | notchedOutline | Styles applied to the NotchedOutline element. |
.MuiOutlinedInput-input | input | Styles applied to the input element. |
.MuiOutlinedInput-inputSizeSmall | inputSizeSmall | Styles applied to the input element if size="small" . |
.MuiOutlinedInput-inputMultiline | inputMultiline | Styles applied to the input element if multiline={true} . |
.MuiOutlinedInput-inputAdornedStart | inputAdornedStart | Styles applied to the input element if startAdornment is provided. |
.MuiOutlinedInput-inputAdornedEnd | inputAdornedEnd | Styles applied to the input element if endAdornment is provided. |
.MuiOutlinedInput-inputTypeSearch | inputTypeSearch | Styles applied to the input element if type="search" . |
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
styleOverrides
property in a custom theme.