Components
- Accordion
- Alert
- Alert Dialog
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Card
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Dialog
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Label
- Menu
- Meter
- Number Field
- Pagination
- Popover
- Preview Card
- Progress
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Slider
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Toolbar
- Tooltip
Resources
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 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="[email protected]"
aria-label="Email"
/>
</div>
)
}
Installation
pnpm dlx shadcn@latest add https://coss.com/ui/r/label.json
Usage
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 function CheckboxDemo() {
return (
<Label>
<Checkbox />
Accept terms and conditions
</Label>
)
}
On This Page