Text Fields

Text fields allow users to enter and edit text.

The TextField wrapper component is a complete form control including a label, input and help text.

Filled Variation

Unifi also recommends a filled variation to improve scan-ability on more complex data entry forms and task-based user interfaces.

Components

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

You might also have noticed that some native HTML input properties are missing from the TextField component. This is on purpose. The component takes care of the most used properties, then it's up to the user to use the underlying component shown in the following demo. Still, you can use inputProps (and InputProps, InputLabelProps properties) if you want to avoid some boilerplate.

Input Adornments

An Input allows the provision of InputAdornment. These 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.

With icon

Icons can be specified as prepended or appended.

Layout

Both TextField and FormControl allow the specification of margin to alter the vertical spacing of inputs. Using none (default) will not apply margins to the FormControl, whereas dense and normal will as well as alter other styles to meet the specification.

Limitations

The input label "shrink" state isn't always correct. The input label is supposed to shrink as soon as the input is displaying something. In some circumstances, we can't determine the "shrink" state (number input, datetime input, Stripe input, dynamically generated field). You might notice an overlap, such as with an adornment.

To workaround the issue, you can force the "shrink" state of the label, such as:

<TextField InputLabelProps={{ shrink: true }} />

or

<InputLabel shrink>Count</InputLabel>

Properties