Label
A semantic and accessible label component that extends HTML label functionality with consistent styling and enhanced features. Perfect for form elements and interactive components.
Install Dependencies
npx quickcode-ui add Label
Default Usage
Default Label
Required Field Indicator
Required Field
Label Variants
Label Variants
Label Sizes
Label Sizes
Props
Prop | Type | Default | Description |
---|---|---|---|
size | "sm" | "md" | "lg" | "md" | Size variant that affects text size |
variant | "default" | "muted" | "accent" | "default" | Visual style variant of the label |
required | boolean | false | Shows a red asterisk (*) indicator for required fields |
children | React.ReactNode | - | The label text or content |
...props | LabelHTMLAttributes | - | All standard HTML label attributes (htmlFor, onClick, etc.) |
Features
- Semantic HTML: Built on native label element for proper accessibility
- Screen Reader Friendly: Properly associates labels with form controls
- Required Field Support: Built-in asterisk indicator for required fields
- Flexible Styling: Multiple variants and sizes for different use cases
- Keyboard Accessible: Full keyboard navigation support
- Dark Mode Ready: Automatic support for light and dark themes
- Disabled State Handling: Automatically styles for disabled form controls
The Label component automatically handles the disabled state styling when used with disabled form controls through CSS peer selectors, ensuring consistent visual feedback across your forms.
Last updated on