Skip to content

Forms

Field

An accessible layout wrapper for one form control.

stableNo JS requiredhydrateless/field.css

An accessible layout wrapper for a single form control: a label, the control, optional help text, and a validation message, all wired together. CSS-only.

Field

Live

We never share it.

Invalid state

Add data-hl-invalid to the field and render an .hl-error message.

Live

Enter a valid email address.

Props

The framework bindings expose these props (and forward the rest to the root element).

PropTypeDefaultDescription
requiredbooleanfalseShow the required marker on the label.
invalidbooleanfalseApply the error styling to the field.

CSS variables

Override these on any ancestor to theme the component. See the theme studio to preview changes live.

CSS variableUsed for
--hl-fg-mutedHelp text color.
--hl-dangerError text and required marker color.
--hl-space-2Gap between label, control, and message.

Accessibility

  • In React, spreading useField() links the control to its label, help, and error via aria-describedby.
  • Set aria-invalid="true" on the control when invalid so the error is announced.

Released under the MIT License.