Label
A control’s label in body text.
With a control
import { Input } from "@applecn/ui/components/input"
import { Label } from "@applecn/ui/components/label"
export default function LabelBasic() {
return (
<div className="flex max-w-sm flex-col gap-2">
<Label htmlFor="label-name">Name</Label>
<Input id="label-name" placeholder="Required" />
</div>
)
}Install
From the registry this site publishes, with dependencies resolved by the CLI.
npx shadcn@latest add https://applecn.vercel.app/r/label.jsonSource
packages/ui/src/components/label.tsx
"use client"
import { cn } from "cn"
import type { ComponentProps } from "react"
/**
* A control's label (HIG › Labels): body text, never dimmed unless the control is disabled.
* Base UI renders toggles as a `<span>`, so the disabled state travels on `data-disabled`
* rather than the `:disabled` pseudo-class — matched whether the control is wrapped or beside.
*/
function Label({ className, ...props }: ComponentProps<"label">) {
return (
<label
data-slot="label"
className={cn(
"flex items-center gap-2 type-body text-label select-none peer-data-disabled:cursor-not-allowed peer-data-disabled:opacity-40 has-data-disabled:cursor-not-allowed has-data-disabled:opacity-40",
className
)}
{...props}
/>
)
}
export { Label }