Skip to content
Form Patterns

Field

A composable form field system that links labels, hints, and error messages to inputs through shared context. Handles accessibility attributes automatically.

This is how others will see you.

Import

import {
  Field,
  FieldLabel,
  FieldHint,
  FieldError,
} from "@mikenotthepope/substrateui"

Composition

Field
├── FieldLabel
├── FieldHint
└── FieldError

Error State

Complete Example

Your legal first and last name.

We use this for account recovery.

Accessibility

Field automatically links FieldLabel to the input via htmlFor, and connects FieldHint and FieldError via aria-describedby, so screen reader users hear the label, the hint, and any validation error as a single unit.

FieldError uses role="alert" so screen readers announce validation errors the moment they appear, without the user needing to navigate back to the field.

Always include a FieldLabel. Placeholder text is not a substitute for a label — it disappears when users start typing and is often low-contrast.

API Reference

Field

PropTypeDefaultDescription
errorbooleanfalseWhen true, applies error styling to child inputs and labels. Adds red border to inputs and red text to labels.
idstringauto-generatedExplicit ID for the field. When omitted, a unique ID is generated automatically via React.useId().
classNamestringAdditional CSS classes to apply to the field wrapper.

FieldLabel

PropTypeDefaultDescription
children
required
React.ReactNodeThe label text content.
classNamestringAdditional CSS classes to apply to the label element.

FieldHint

PropTypeDefaultDescription
children
required
React.ReactNodeHelper text displayed below the input.
classNamestringAdditional CSS classes to apply to the hint paragraph.

FieldError

PropTypeDefaultDescription
childrenReact.ReactNodeThe error message. When empty or undefined, the element does not render at all.
classNamestringAdditional CSS classes to apply to the error paragraph.