Components
Label
a form label with disabled and invalid state styling
Installation
pnpm dlx shadcn@latest add https://prototyper-ui.com/r/label.jsonnpx shadcn@latest add https://prototyper-ui.com/r/label.jsonyarn dlx shadcn@latest add https://prototyper-ui.com/r/label.jsonbunx --bun shadcn@latest add https://prototyper-ui.com/r/label.jsonThis will add the following files to your project:
components/ui/label.tsx
Usage
import { Label } from "@/components/ui/label"<Label>Email address</Label>Examples
With Input
Loading...
Styling
Data Slots
Use data-slot attributes to target the label in CSS:
| Slot name | Element |
|---|---|
label | The <label> root |
Customization Examples
/* Make all labels uppercase */
[data-slot="label"] {
@apply text-xs uppercase tracking-wide;
}<Label className="text-base font-semibold">Custom label</Label>API Reference
Label
A styled <label> element for form controls.
Prop
Type
All standard label element props are forwarded via ...props.
Accessibility
Keyboard Interactions
Label is a non-interactive display element and does not have keyboard interactions. Clicking a label focuses or activates its associated form control via the htmlFor attribute or nesting.
ARIA Attributes
- Renders as a native
<label>element. - Associates with a form control via
htmlForor by wrapping the control. - Automatically receives
data-disabledanddata-invalidstyling from parentFieldor group contexts.