Label
Label renders a <label> for a form control. Inside a Field it resolves htmlFor from context,
so the label and the control are linked without you wiring an id by hand.
What it is
A Text rendered as <label>. Inside a Field it reads the field id from context and sets
htmlFor to it; outside a Field, pass htmlFor yourself. When the surrounding Field is
required, Label appends a marker after the label text.
Install
Label is exported from usemotif. No separate install.
API
Label
stablefunction Label(props: LabelProps): JSX.Element
The id of the control this labels. Optional inside a Field — the field id is resolved from context. Required when used standalone.
Every Text prop. Label renders as `<label>` with semibold, small-size defaults.
Accessibility
A <label> linked to its control through htmlFor does two things: it gives the control an
accessible name, and it widens the click target — clicking the label focuses the control. Inside a
Field the link is automatic. Standalone, supply htmlFor and match it to the control's id; a
Label with no target labels nothing.
The required marker is decorative — it carries aria-hidden. The machine-readable signal is the
control's aria-required, which Field sets.
Examples
Inside a Field — no htmlFor needed:
Standalone — wire htmlFor to the control id: