Field puts a label above a control, a hint under it and an error when there is one, and connects them. The control gets its id, aria-describedby, aria-invalid and aria-required from the field, merged with any it already has, so a screen reader hears the error the moment it appears.
- The label's htmlFor points at the control's id. The control keeps its own id; a control without one gets a generated id.
- aria-describedby lists the control's own description first, then the error, then the hint.
- While error is set the control is aria-invalid. Input (with any type, "password" included), Textarea and the fields built on them, such as Select and NumberInput, also draw their error styling, with no separate error prop.
- required adds aria-required and an asterisk after the label. The asterisk is hidden from screen readers so it is not read out twice.
The hint stays visible while the error shows, so the instruction is still there when the user goes back to fix the value.
Input and Textarea work on their own: a floating label inside the box, and description and errorMessage under it at the same 16px inset as the text. That suits a single field, like a search box or a settings row.
In a form, wrap each control in a Field. The label sits above the box, the hint and error start under the label, and every control in the form, Select or a custom picker included, looks the same. FormErrorSummary links to the ids a Field wires.
Inside a Field, give the label, hint and error to the Field and leave the control's own label, description and errorMessage unset. Set both and you get two labels, and messages at two different insets; in development the control warns in the console.
Native elements and third-party controls get the same props. For a control that needs them somewhere other than its root, pass a function: it receives the props to spread.
A custom control can also read the field from context with useField(), which returns the id, invalid, required and describedBy of the enclosing field, or null outside one.
A Field takes span like any other field, and lays out in a Form grid. With density="stacked" the controls still fuse; the labels and messages sit outside the group's border.