Label

Base

Accessible form label with required indicator support.

Preview

Usage

example.jsx
import { Label } from "@/components/ui/label";

export default function Example() {
  return <Label />;
}

Source Code

Copy this file into components/ui/label.jsx in your project.

label.jsx
"use client";

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

const Label = forwardRef(({ className, ...props }, ref) => {
  return (
    <label
      ref={ref}
      className={cn(
        "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
        className
      )}
      {...props}
    />
  );
});
Label.displayName = "Label";

export { Label };

Quick Install

Make sure you have the cn() utility set up. It requires clsx and tailwind-merge.

npm install clsx tailwind-merge