sigilUI

Field

A form field wrapper that connects a label, input, description, and error message with accessible aria attributes.

@sigil-ui/componentsReact

Preview

Live preview Interactive

Import

import { Field, FieldLabel, FieldDescription, FieldError } from "@sigil-ui/components";

Usage

<Field>
  <FieldLabel>Email address</FieldLabel>
  <Input type="email" placeholder="you@example.com" />
  <FieldDescription>We'll never share your email.</FieldDescription>
</Field>

With error

<Field invalid>
  <FieldLabel>Username</FieldLabel>
  <Input placeholder="Choose a username" />
  <FieldError>Username is already taken.</FieldError>
</Field>

Required field

<Field required>
  <FieldLabel>Password</FieldLabel>
  <Input type="password" />
  <FieldDescription>Minimum 8 characters.</FieldDescription>
</Field>

Horizontal layout

<Field orientation="horizontal">
  <FieldLabel>Notify me</FieldLabel>
  <Switch />
</Field>

Token integration

CSS VariableUsed for
--s-textLabel text color
--s-text-mutedDescription text color
--s-errorError message and invalid border
--s-font-bodyFont family
--s-space-2Gap between label, input, and description

Props

Field

PropTypeDefaultDescription
invalidbooleanfalseShow error state on children
requiredbooleanfalseMark as required
disabledbooleanfalseDisable all children
orientation"vertical" | "horizontal""vertical"Layout direction
classNamestring—Additional CSS classes
childrenReactNode—Field content

Accessibility

  • Auto-generates id and wires aria-labelledby, aria-describedby, and aria-errormessage
  • required adds aria-required="true" to the input
  • invalid adds aria-invalid="true" to the input