A text label that pairs with form controls, with automatic disabled state handling.
A styled <label> element that displays text alongside form controls. It automatically adjusts its appearance when its associated control is disabled, using both group-data-[disabled=true] and peer-disabled modifiers.
import { Label } from "@/components/ui/label"
export default function LabelDemo() {
return <Label htmlFor="name">Name</Label>
}
import { Label } from "@/components/ui/label"<Label htmlFor="email">Email</Label><div className="grid gap-2">
<Label htmlFor="name">Name</Label>
<input id="name" type="text" />
</div>Use Label inline with a checkbox for a clickable label area.
<div className="flex items-center gap-2">
<input id="terms" type="checkbox" className="peer" />
<Label htmlFor="terms">Accept terms and conditions</Label>
</div>When the associated input is a peer and is disabled, the label automatically reduces opacity and disables pointer events.
<div className="flex items-center gap-2">
<input id="disabled" type="checkbox" className="peer" disabled />
<Label htmlFor="disabled">Disabled option</Label>
</div>Renders a <label> element with flex layout, small text, and automatic disabled state handling.
| Prop | Type | Default | Description |
|---|---|---|---|
htmlFor | string | — | The id of the form element the label is associated with. |
className | string | — | |
children | ReactNode | — |
Accepts all standard HTML <label> attributes.