quadratic/ui

Label

Renders an accessible label associated with controls.

Installation

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(
        "leading-none relative text-3.5 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>