Label
A caption for a form control — input, checkbox, radio, switch, select. Renders a native <label>. Pair every form control with a Label so the control has an accessible name, clicks on the label focus the control, and screen readers announce the field correctly.
When to use
- Every visible form control. Always.
- Above or beside an input to describe it ("Email", "API key").
- Wrapping a checkbox or radio next to its descriptive text.
When not to use
- For static UI text that isn't labeling a control, use a heading or plain
<p>/<span>. - As a substitute for
aria-labelon non-<input>widgets that don't support<label for>association.
Two ways to associate
Either wrap the control inside the <Label> (implicit association — simplest) or set htmlFor to the control's id (explicit — required when the control isn't a child).
For the explicit form, React's useId() is the easiest way to generate a unique, SSR-stable id without hand-managing strings:
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:
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.