label.tsx

1"use client"
2
3import * as React from "react"
4import * as LabelPrimitive from "@radix-ui/react-label"
5import { cva, type VariantProps } from "class-variance-authority"
6
7import { cn } from "@/lib/utils"
8
9const labelVariants = cva(
10  "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
11)
12
13const Label = React.forwardRef<
14  React.ElementRef<typeof LabelPrimitive.Root>,
15  React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
16    VariantProps<typeof labelVariants>
17>(({ className, ...props }, ref) => (
18  <LabelPrimitive.Root
19    ref={ref}
20    className={cn(labelVariants(), className)}
21    {...props}
22  />
23))
24Label.displayName = LabelPrimitive.Root.displayName
25
26export { Label }