Skip to content

Label

A form label.

For a field

Around a control

Disabled

Installation

npx shadcn@latest add @khaeli/label

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

Registry items

Accessible name

  • htmlFor is the id of the control. The label's text becomes the control's name, and a click on the label focuses or toggles the control.
  • A label may wrap its control instead: the text beside the control names it, and no id is needed.
  • One label per control. Text that explains the value belongs in a description that the control lists in aria-describedby.
  • The label dims with its field when an ancestor with the class group carries data-disabled="true". Disable the control itself as well: the dimming is only visual.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/label.json