Label
A text label component that provides names for form controls.
Usage
Label Props
Prop | Type | Default |
---|---|---|
size | "small" | "medium" | "large" | "small" |
required | boolean | - |
requiredIndicator | string | "*" |
htmlFor | string | - |
className | string | - |
Examples
Size
Labels have 3 different sizes.
Required
Labels can indicate required fields with either a default asterisk or custom text.
Accessibility
The Label component is designed with accessibility in mind:
- Uses semantic HTML
<label>
element - Supports programmatic association with form controls via
htmlFor
- Required indicators are properly hidden from screen readers
- Maintains WCAG compliant color contrast ratios
- Supports keyboard navigation when used with form controls