Skip to main content

Text Field

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

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.

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.



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

Kg

Weight



Icons

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



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.



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



Components

TextField is composed of smaller components (FormControl, Input, FilledInput, InputLabel, OutlinedInput, and FormHelperText) that you can leverage directly to significantly customize your form inputs.

Some important helper text

Disabled

Error



Inputs


Customized

Use styled hook to customize your text field.