Form Control
The FormControl component adds a label and caption for its child control.
If an error message is passed it renders that message in place of the caption.
Note, the FormControl expects a single child component.
If that child has an id prop, the label in the form control will assign the htmlFor accordingly.
Examples
Note, for a Checkbox, the actual label is the accompanying text on the right side of the checkbox element.
Note, for a Radio/RadioGroup, the actual label is the accompanying text on the right side of the radio element.
The positive and error props accept both boolean and string values.
If you pass a string, it will be used as the caption of the form control, overriding any value passed to the caption prop.
The example above showcases this behavior.
API
Form Control exports
You can import this module like so:
import {FormControl} from 'baseui/form-control'
It exports the following components or utility functions:
- FormControl
- StyledLabel
- StyledCaption
- StyledControlContainer