Field
Associate a control with its label, help, error, and inherited state.
Field is a standalone presentational component with no form validation or form integration.
It is used only for rendering field UI, registering controls, inheriting state, and establishing ARIA relationships.
For form integration, use form.Field returned by createForm().
Basic usage#
Playground#
Enter an invalid email and leave the input to show the error and enable its slot indicator.
Use your work email address.
Anatomy#
Help and error are mutually exclusive; the error replaces help when the field is invalid.
Usage#
Put a Moraine control inside Field so its label, description, and error IDs are registered with the actual focusable element. Standalone Field does not validate or submit values; use form.Field from createForm() when a schema owns the field. For local validation, pass the current message to error.
Visually hidden labels#
Use hiddenLabel when a compact control needs an accessible name without a visible label.
It preserves the label association without reserving label spacing or an empty horizontal label column.
A non-empty label takes precedence over hiddenLabel. Hint and description text remain visible;
help and error text keep their usual placement.
For a switch with a trailing visible label, use <Switch label="Auto refresh" />.
Examples#
Inherited state#
Manual validation#
Horizontal layout#
Attributes#
data-requiredSlot: field-labelDescription: Present when the field input is required.data-has-textSlot: field-containerDescription: Present when the control currently contains text.Props#
Props for the Field component. Renders a <div> element by default.