Command Palette

Search for a command to run...

Field

Pairs a label with the control it names.

Usage

import { Field } from "@smartacteam/ambient-web/field";
<Field.Root>
  <Field.Label>Company name</Field.Label>
  <Field.Control render={<Input.Text />} />
</Field.Root>

Field.Root names its control from Field.Label and describes it from Field.Description, so no ids need passing by hand.

Why the label is not a <label>

A browser forwards :hover to the control a <label> labels, so a label associated the usual way puts its control into the hover state whenever the pointer crosses the label text — which can sit a column or more away from the control. Wrapping the control in the label does the same thing.

Field.Label renders a <span> and keeps the association through aria-labelledby, so hover stays where the pointer is. Clicking the label still reaches the control.

Examples

Description