Components
- Accordion
- Alert
- Alert Dialog
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Card
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Dialog
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Label
- Menu
- Meter
- Number Field
- Pagination
- Popover
- Preview Card
- Progress
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Skeleton
- Slider
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Toolbar
- Tooltip
Label
Renders an accessible label associated with controls.
import { useId } from "react"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
export default function InputWithLabel() {
const id = useId()
return (
<div className="flex flex-col items-start gap-2">
<Label htmlFor={id}>Email</Label>
<Input
id={id}
type="email"
placeholder="you@example.com"
aria-label="Email"
/>
</div>
)
}
Installation
npx love-ui@latest add labelUsage
import { Label } from "@/components/ui/label"<Label htmlFor="email">Email</Label>Examples
For accessible labelling and validation, prefer using the FieldLabel component. See some related examples.
With Checkbox
import { Checkbox } from "@/components/ui/checkbox"
import { Label } from "@/components/ui/label"
export default function CheckboxDemo() {
return (
<Label>
<Checkbox />
Accept terms and conditions
</Label>
)
}