kanso/ui
Form

Label

An accessible caption for a form control.

LiveRev. 01

Installation

CLI

$ npx shadcn@latest add https://konsa.rohitxyz.me/r/label.json

Manual

Install the dependencies

npm install radix-ui

Copy the source into your project

components/ui/label.tsx
"use client";

import * as React from "react";
import { Label as LabelPrimitive } from "radix-ui";

import { cn } from "@/lib/utils";

function Label({
  className,
  ...props
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
  return (
    <LabelPrimitive.Root
      data-slot="label"
      className={cn(
        "flex items-center gap-2 text-sm leading-none font-medium select-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
        className,
      )}
      {...props}
    />
  );
}

export { Label };

Update the import paths to match your project

The file imports cn from @/lib/utils. See installation.

Usage

import { Label } from "@/components/ui/label";
<Label htmlFor="email">Email</Label>
Label