Component
label-demo
not found in registry.
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
export default function LabelDemo() {
return (
<div className="grid w-full max-w-sm items-center gap-1.5">
<Label htmlFor="email">Email</Label>
<Input type="email" id="email" placeholder="Email" />
</div>
)
}
Not found
Installation
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { ark } from "@ark-ui/react/factory"
import { type VariantProps, cva } from "class-variance-authority"
import { cn } from "@/lib/utils"
const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
)
export interface LabelProps
extends React.LabelHTMLAttributes<HTMLLabelElement>,
VariantProps<typeof labelVariants> {
asChild?: boolean
}
const Label = React.forwardRef<HTMLLabelElement, LabelProps>(
({ className, htmlFor, children, ...props }, ref) => (
<ark.label
ref={ref}
className={cn(labelVariants(), className)}
htmlFor={htmlFor}
{...props}
>
{children}
</ark.label>
)
)
Label.displayName = "Label"
export { Label }
Not Found
Update the import paths to match your project setup.
Usage
import { Label } from "@/components/ui/label"
<Label htmlFor="email">Your email address</Label>