Label
Renders an accessible label associated with controls.
Installation
Follow the Quickstart guide if you haven't already.
Install the following dependencies:
pnpm add @radix-ui/react-label
Copy and paste the following code into your project.
import * as LabelPrimitive from "@radix-ui/react-label";
import { cn } from "~/utils/tailwind";
function Label({
className,
...props
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
return (
<LabelPrimitive.Root
className={cn(
"text-3.5 relative leading-none font-medium",
"peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
className,
)}
{...props}
/>
);
}
export { Label };
Update the import paths to match your project setup.
Usage
import { Label } from "~/components/ui/Label";
<Label htmlFor="email">Your email address</Label>