Label
FormAccessible label element that pairs with form inputs.
Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.
"use client";
import { Label } from "@dashboardpack/core/components/ui/label";
import { Input } from "@dashboardpack/core/components/ui/input";
import { Checkbox } from "@dashboardpack/core/components/ui/checkbox";
export default function LabelExample() {
return (
<div className="w-full max-w-sm space-y-5">
<div className="space-y-2">
<Label htmlFor="label-name">
Display name <span className="text-destructive">*</span>
</Label>
<Input id="label-name" required placeholder="Alex Morgan" />
</div>
<div className="flex items-center gap-2">
<Checkbox id="label-updates" />
<Label htmlFor="label-updates">Send me product updates</Label>
</div>
</div>
);
}Usage
Link labels to controls with matching htmlFor and id values. Explain required fields in visible text as well as with the native required attribute.
import { Label } from "@dashboardpack/core/components/ui/label";Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.
API reference
Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.
| Prop | Type / Default | Description |
|---|---|---|
| htmlFor | stringDefault: — | The id of the labeled control. |
| children | ReactNodeDefault: — | Visible field name. |
| className | stringDefault: — | Extend label styling. |