Components

Label

The words that go with a field, in the bold hand font, with an optional red pencil star for required fields. It fades with a disabled control and hands its click to it.

Install

terminal
npx shadcn@latest add @wobko/label

First time here? Add the registry to components.json first. How to install

Examples

Default

Click the words and the field takes focus.

Required

The star is drawn, not typed, and it is decorative: required on the control is what a screen reader hears.

Dimmed with a disabled control

A label after a peer control fades to graphite when the control is disabled: checkbox as a peer, a drawn Input marked peer, or a group with data-disabled.

Accept terms

shadcn's `label-demo`: a Label next to a Checkbox, joined by `htmlFor` and `id`. Click the words and the box ticks itself; the row is the hit area.

API reference

Label

Radix Label.Root (a real <label>). htmlFor or nesting associate it with a control; double-clicking its text does not select it. required draws a star after the text.

PropTypeDefaultDescription
requiredbooleanfalseA red-pencil star after the text: three crossing strokes, drawn once per label. It is decorative (aria-hidden) and adds nothing to the accessible name: put required on the control so it is announced.
seedstring | number-Pins the hand of the star. Default: derived from useId().
htmlForstring-The id of the control.

Accessibility

  • A native <label>: clicking it focuses or toggles its control; the control's accessible name is the label's text (the star is aria-hidden).
  • Bold Kevin Sans at 15 px in ink on paper (14:1). Disabled controls dim their label: put peer on the control before the label (peer-disabled), on a drawn Input / Textarea frame (peer-has-[>input:disabled]), or wrap both in a group with data-disabled="true".
  • The star is intrinsic art: it stays visible in Windows high contrast and never takes focus.

Source

The files the CLI copies into your project.

Loading the source