Skip to main content

Label

A caption for a form control, such as an input, a checkbox, a radio, a switch, or a select. Wrap the control in the Label, or set htmlFor to the control's id.

When to use

  • Give every visible form control a caption. A Label renders a native <label>, so the control gets an accessible name, a click on the label focuses the control, and screen readers announce the field correctly.
  • Describe an input above or beside it ("Email", "API key").
  • Wrap a checkbox or a radio next to its descriptive text.
  • Use a heading or a plain <p> or <span> for static UI text that does not label a control.
  • Do not use a Label as a substitute for aria-label on widgets other than <input> that do not support <label for> association.
  • Prefer Field when the control also needs a description or validation errors.
  • Prefer Choice when the control needs a title and a description beside it.

Two ways to associate

Wrap the control inside the <Label> for implicit association, the simplest form. Set htmlFor to the control's id for explicit association. The control must use the explicit form when it is not a child of the label.

For the explicit form, React's useId() generates a unique, SSR-stable id, so you do not manage id strings by hand. The example at the top of this page uses it.

With TanStack Form

When you're using TanStack Form, field.name is already a stable, unique string for each field: pass it as both htmlFor on the Label and id on the input. You get a guaranteed-correct association for free without calling useId() separately:

Font weight

A Label automatically gets font-medium when it doesn't contain a nested form control (<input>, <textarea>, <select>, <button>, or [contenteditable]). The default is detected via :has() and applied through a :where()-wrapped variant so its specificity is 0; any font-weight utility you pass on the Label itself overrides cleanly:

Label that wraps a control

When the Label wraps a control, the auto-default is skipped on purpose: otherwise the control's own typography would inherit the medium weight from the label. In that case, apply font-medium to your own caption element (a <span> or <p>) inside the label:

Disabled state

Pass disabled to render the label in a disabled style. Typically you'll want this to mirror the underlying control's disabled state so the visual treatment stays consistent.

API Reference

The Label accepts the following props in addition to the standard HTML label attributes.

PropTypeDefaultDescription
disabledbooleanfalseUse the disabled prop to explicitly render the label in a disabled state.