InputBase API
API reference docs for the React InputBase component. Learn about the props, CSS, and other APIs of this exported module.
Component demos
Import
import InputBase from '@mui/material/InputBase';
// or
import { InputBase } from '@mui/material';
InputBase
contains as few styles as possible.
It aims to be a simple building block for creating an input.
It contains a load of style reset and some state logic.
Props of the native 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' | 'error' | 'info' | 'success' | 'warning' | 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. |
componentsProps | { input?: object, root?: object } | {} | The extra props for the slot components. You can override the existing props or add new ones. |
defaultValue | any | The default value. Use when the component is not controlled. | |
disabled | bool | If | |
disableInjectingGlobalStyles | bool | false | If |
endAdornment | node | End | |
error | bool | If | |
fullWidth | bool | false | If |
id | string | The id of the | |
inputComponent | element type | 'input' | The component used for the |
inputProps | object | {} | Attributes applied to the |
inputRef | ref | Pass a ref to 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 | |
onBlur | func | Callback fired when the | |
onChange | func | Callback fired when the value is changed. Signature: function(event: React.ChangeEvent
| |
onInvalid | func | Callback fired when the | |
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. | |
size | 'medium' | 'small' | string | The size of the component. | |
slotProps | { input?: object, root?: object } | {} | The extra props for the slot components. You can override the existing props or add new ones. |
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.Theme default props
You can use MuiInputBase
to change the default props of this component with the theme.
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 |
---|---|---|
.Mui-disabled | Styles applied to the root element if disabled={true} . | |
.Mui-error | State class applied to the root element if error={true} . | |
.Mui-focused | Styles applied to the root element if the component is focused. | |
.Mui-readOnly | State class applied to the root element if readOnly={true} . | |
.MuiInputBase-adornedEnd | adornedEnd | Styles applied to the root element if endAdornment is provided. |
.MuiInputBase-adornedStart | adornedStart | Styles applied to the root element if startAdornment is provided. |
.MuiInputBase-colorSecondary | colorSecondary | Styles applied to the root element if the color is secondary. |
.MuiInputBase-formControl | formControl | Styles applied to the root element if the component is a descendant of FormControl . |
.MuiInputBase-fullWidth | fullWidth | Styles applied to the root element if fullWidth={true} . |
.MuiInputBase-input | input | Styles applied to the input element. |
.MuiInputBase-inputAdornedEnd | inputAdornedEnd | Styles applied to the input element if endAdornment is provided. |
.MuiInputBase-inputAdornedStart | inputAdornedStart | Styles applied to the input element if startAdornment is provided. |
.MuiInputBase-inputHiddenLabel | inputHiddenLabel | Styles applied to the input element if hiddenLabel={true} . |
.MuiInputBase-inputMultiline | inputMultiline | Styles applied to the input element if multiline={true} . |
.MuiInputBase-inputSizeSmall | inputSizeSmall | Styles applied to the input element if size="small" . |
.MuiInputBase-inputTypeSearch | inputTypeSearch | Styles applied to the input element if type="search" . |
.MuiInputBase-multiline | multiline | Styles applied to the root element if multiline={true} . |
.MuiInputBase-root | root | Styles applied to the root element. |
.MuiInputBase-sizeSmall | sizeSmall | Styles applied to the input element if size="small" . |
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.