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 add field

Usage

import {
  Field,
  FieldLabel,
  FieldDescription,
  FieldError,
} from "@/components/ui/field"
<Field>
  <FieldLabel htmlFor="email">Email address</FieldLabel>
  <Input id="email" type="email" placeholder="you@example.com" />
  <FieldDescription>We will never share your email.</FieldDescription>
</Field>

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.

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