Label
A form label with optional required marker, for controls that don't render their own.
When you need it
Input, Textarea, and Select all take a label prop and render this for you. Use it directly for controls that don't, like a bare Switch or a custom field of your own.
Required
Paired with a field
htmlFor has to match the control's id. That's what makes clicking the label focus the field and what screen readers use to announce it.
Props
Every other native attribute is forwarded to the underlying <label>.
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | Label text. | |
| required | boolean | false | Appends a red asterisk. |
| htmlFor | string | Id of the control this labels. Always set it, so clicking the label focuses the field. |