UIIcons

Field

A form field layout system that pairs labels, inputs, descriptions, and error messages.

We will never share your email.

Installation

pnpm dlx stera-ui@latest add field

Composition

Field

A single control with label, helper text, and validation.

Field
├── FieldLabel
├── Input / Textarea / Switch / Select
├── FieldDescription
└── FieldError

FieldGroup

Related fields in one group. Use FieldSeparator between sections when needed.

FieldGroup
├── Field
│   ├── FieldLabel
│   ├── Input / Textarea / Switch / Select
│   ├── FieldDescription
│   └── FieldError
├── FieldSeparator
└── Field
    ├── FieldLabel
    └── Input / Textarea / Switch / Select

FieldSet

Semantic grouping with a legend and description, usually containing a FieldGroup.

FieldSet
├── FieldLegend
├── FieldDescription
└── FieldGroup
    ├── Field
    │   ├── FieldLabel
    │   ├── Input / Textarea / Switch / Select
    │   ├── FieldDescription
    │   └── FieldError
    └── Field
        ├── FieldLabel
        └── Input / Textarea / Switch / Select

Anatomy

The Field family is designed for composing accessible forms. A typical field is structured as follows:

<Field>
  <FieldLabel htmlFor="input-id">Label</FieldLabel>
  {/* Input, Select, Switch, etc. */}
  <FieldDescription>Optional helper text.</FieldDescription>
  <FieldError>Validation message.</FieldError>
</Field>
  • Field is the core wrapper for a single field.
  • FieldContent is a flex column that groups label and description. Not required if you have no description.
  • Wrap related fields with FieldGroup, and use FieldSet with FieldLegend for semantic grouping.

Examples

Horizontal Layout

Marketing emails

Receive emails about new products, features, and more.

Use orientation="horizontal" to place label/description on the left and the control on the right. Ideal for toggle rows.

With Error

Add data-invalid="true" to Field and aria-invalid="true" to the input to trigger error styles.

Multiple Errors

Pass an errors array to FieldError to list multiple validation messages.

Disabled

This field cannot be edited.

Checkbox Group

Notifications

Select which notifications you would like to receive.

Use FieldSet and FieldLegend to group related checkboxes or radio buttons with a shared label.

Full Form Example

Brief description for your profile.

Marketing emails

Receive emails about new products and features.

Accessibility

  • FieldSet and FieldLegend keep related controls grouped for keyboard and assistive tech users.
  • Field outputs role="group" so nested controls inherit labeling from FieldLabel and FieldLegend when combined.
  • Apply FieldSeparator sparingly to ensure screen readers encounter clear section boundaries.

API Reference

Field

PropTypeDefault
orientation"vertical" | "horizontal" | "responsive""vertical"
data-invalid"true"
data-disabled"true"

FieldError

PropTypeDefault
errorsArray<{ message: string }>

FieldLegend

PropTypeDefault
variant"default" | "label""default"

Subcomponents

ComponentDescription
FieldLabel<label> element styled for the design system
FieldDescriptionSupporting helper text
FieldErrorError message(s) displayed when invalid
FieldGroupVertical stack of multiple Field components
FieldSetFieldset wrapper for grouped controls
FieldLegendLegend/heading for a FieldSet
FieldContentColumn of FieldTitle + FieldDescription for horizontal layouts
FieldTitleBold title inside FieldContent
FieldSeparatorHorizontal divider between field groups, with optional label