Backbencher.dev

Make Material UI TextField As Required Field

Last updated on 19 Aug, 2021

We can use TextField component in Material UI to show input textbox.

import TextField from "@material-ui/core/TextField";

When using the TextField component, we can pass the required attribute to mark the component as required.

<TextField required id="shop-name" label="Shop Name" variant="outlined" />

Having required attribute prevents the form to be submitted if the field is empty.

--- ○ ---
Joby Joseph
Web Architect