Skip to main content

Text Field

Please refer to MUI's official docs for more details on component's usage guide and API documentation.

Custom

Use the CustomTextField component for the custom variant.



Variants

Use variant={'filled' | 'standard'} prop for different text fields.



Form Props

Standard form attributes are supported e.g. required, disabled, type, etc. as well as helperText which is used to give context about a field's input, such as how the input will be used.

helper text

Some important text



Controlled and Uncontrolled

Manage value prop with the help of a state for controlled TextField and use defaultChecked prop for uncontrolled TextField.



Sizes

Use size prop for different sizes of text fields.



Color

color={'secondary' | 'success' | 'error' | 'warning' | 'info'} prop changes the highlight color of the text field when focused.

helper text

helper text

helper text

helper text

helper text



Icons

There are multiple ways to display an icon with a text field.



Input Adornment

The main way is with an InputAdornment. This can be used to add a prefix, a suffix or an action to an input. For instance, you can use an icon button to hide or reveal the password.

Kg



Layout

fullWidth can be used to make the input take up the full width of its container.

margin prop can be used to alter the vertical spacing of inputs. Using none (default) doesn't apply margins to the FormControl whereas dense and normal do.

Some important text

Some important text

Some important text



Validation

The error prop toggles the error state, the helperText prop can then be used to provide feedback to the user about the error.

Incorrect entry.