Skip to content

Field

Field is the layout wrapper that wires a form control to its label, helper description, and validation message. Instead of hand-aligning a label, input, and error, you compose Field from its slotted parts so every form across Helm shares the same spacing, invalid styling, and accessibility wiring.

Live demo

The interactive story below runs from the deployed Storybook.

Usage

Source: field.tsx

import {
FieldGroup,
Field,
FieldLabel,
FieldDescription,
FieldError,
Input,
} from "@beacon/design-system";
// A single field with label and helper text.
<FieldGroup>
<Field>
<FieldLabel>Email address</FieldLabel>
<Input type="email" placeholder="you@example.com" />
<FieldDescription>We'll never share your email.</FieldDescription>
</Field>
</FieldGroup>
// Invalid state: set data-invalid and render a FieldError.
<FieldGroup>
<Field data-invalid="true">
<FieldLabel>Username</FieldLabel>
<Input defaultValue="johndoe" />
<FieldError>Username is already taken.</FieldError>
</Field>
</FieldGroup>

Parts

PartRole
FieldA single field row. orientation is "vertical" (default), "horizontal", or "responsive". Set data-invalid="true" to switch on invalid styling.
FieldLabelThe label for the control; renders a Label. Wrapping a nested Field turns it into a selectable card label.
FieldContentOptional column that groups the control plus its description and error (used for checkbox and radio layouts).
FieldTitleTitle text inside a FieldContent, for selectable options that have a heading and supporting text.
FieldDescriptionMuted helper text below the control.
FieldErrorValidation message with alert role. Pass children, or an errors array of { message } objects to render one message or a bulleted list.
FieldGroupContainer that stacks multiple Field rows with consistent spacing.
FieldSetNative <fieldset> wrapper for a related group of fields.
FieldLegendThe <legend> for a FieldSet; variant is "legend" (default) or "label".
FieldSeparatorA horizontal divider between fields, with optional centered label content.

When to use

  • Every labeled form control: pair the label, control, helper text, and error in one consistent block.
  • Grouping related controls with FieldSet and FieldLegend (for example an address block).
  • Horizontal or responsive label layouts via the orientation prop.

Do not scatter a bare Label and control with manual margins. Compose them inside Field so spacing, invalid styling, and the error region stay consistent. The control itself is still an Input, Textarea, Checkbox, or similar primitive.