Free shadcn/ui label component for React, built on Radix Label — accessible form labels bound to inputs by htmlFor, with required and disabled states. Copy or install in one command.

Installation

1 Configure registry — once per project
{
  "registries": {
    "@designrevision": "https://registry.designrevision.com/r/{name}.json"
  }
}

Add to your existing components.json. Requires shadcn/ui v2.3+.

2 Install the component

Packages

@radix-ui/react-label
utils

Props

htmlFor = —
string

Id of the input this label is bound to. Clicking the label then focuses that input.

Extends the Radix Label Root (@radix-ui/react-label) — all native <label> attributes are supported.

Copied!
components/ui/label.tsx
"use client"

import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"

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

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

export { Label }

Examples

Labelled fields

A label bound to an input by `htmlFor`, a required field with an asterisk, and a disabled field whose label dims automatically via `group-data-[disabled]`.

Packages

label
input

Props

No props documented yet.

Copied!
components/ui/label-fields-01.tsx
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

export default function LabelFields01() {
  return (
    <div className="grid w-full max-w-sm gap-6">
      <div className="grid gap-2">
        <Label htmlFor="name">Full name</Label>
        <Input id="name" placeholder="Ada Lovelace" />
      </div>
      <div className="grid gap-2">
        <Label htmlFor="email">
          Email
          <span className="text-destructive">*</span>
        </Label>
        <Input id="email" type="email" placeholder="[email protected]" required />
      </div>
      <div className="group grid gap-2" data-disabled="true">
        <Label htmlFor="account">Account ID</Label>
        <Input id="account" defaultValue="acct_4Xa92" disabled />
      </div>
    </div>
  )
}

Frequently asked questions

A label names a form control so users and screen readers know what an input is for. Bind it to a control with htmlFor matching the control id; clicking the label then focuses the control, which also enlarges the hit target.
Set the label htmlFor to the same value as the input id, for example htmlFor="email" on the label and id="email" on the input. This is the accessible association and is what makes clicking the label focus the field.
No. A placeholder disappears once the user types and is not reliably announced by assistive technology, so it is not a substitute for a label. Use a real label for every field; a placeholder can show an example value in addition.
The label reads its disabled state from the surrounding form group via group-data-[disabled] and from a peer control via peer-disabled, lowering its opacity so the whole field reads as inactive. It is purely visual — the styling follows the control state automatically.
Yes. It is the canonical shadcn/ui label, a thin wrapper over Radix Label, so it drops into any shadcn/ui project and prevents text selection on double-click like the original. It is styled with your theme tokens and works in light and dark mode.