Reputation: 595
hi What's special about FormControl from Material UI? Does it mean that child element is controlled?
<FormControl>
<InputLabel htmlFor="my-input">Email address</InputLabel>
<Input id="my-input" aria-describedby="my-helper-text" />
</FormControl>
Upvotes: 0
Views: 4401
Reputation: 595
If you use FormControl you can pass some props like error and it's gonna make styles for all children we need to show error. You don't have to make styles for every child it's enough to pass some prop to FormControl. Thnx to Francesco Cipolla for examples
Upvotes: 0
Reputation: 73
According to the material-ui documentation:
Provides context such as filled/focused/error/required for form inputs.
You basically use the FormControl component for accessibility reasons when you're building your own Field component(doc reference). It allows you to pass props such as error
and change your UI.
For example the TextField Component is built on top of the FormControl too (doc reference).
N.B. Form fields are controlled when you manually handle (update on changes) their values
You can learn more by checking the Material UI doc
I also live you a CodeSandBox Example here
Upvotes: 2