Field
Accessible form field layout that wires labels, descriptions and errors to a control.
pnpm dlx @glinui/cli@latest add fieldCheckout
Studio keyboard, 75%. $129.00 with free shipping.
Installation
pnpm dlx @glinui/cli@latest add fieldPrefer the package?
Usage
FieldControl wires one child control to its Field. It clones the child and injects the generated id (matching the label htmlFor), aria-describedby pointing at the description and error, aria-invalid when an error is present and aria-required. Put exactly one control inside it.
Unlike shadcn Field, which leaves id and aria wiring to you, Glin UI Field does it through FieldControl, so labels, hints and errors stay connected without manual ids. Controls rendered outside FieldControl are not wired.
Label, description, error
We never share your email.
import { Field, FieldControl, FieldDescription, FieldError, FieldLabel } from "@glinui/ui"import { Input } from "@glinui/ui"
export function Demo() { return ( <Field> <FieldLabel>Email</FieldLabel> <FieldControl><Input type="email" placeholder="name@example.com" /></FieldControl> <FieldDescription>We never share your email.</FieldDescription> <FieldError>Enter a valid email address.</FieldError> </Field> )}Invalid
import { Field, FieldControl, FieldError, FieldLabel } from "@glinui/ui"import { Input } from "@glinui/ui"
export function Demo() { return ( <Field invalid> <FieldLabel>Username</FieldLabel> <FieldControl><Input defaultValue="a" /></FieldControl> <FieldError errors={[{ message: "At least 3 characters" }]} /> </Field> )}Accessibility
- Each Field generates ids so the label `htmlFor`, description and error are wired automatically via FieldControl.
- FieldError uses `role="alert"` so errors are announced.
- `aria-describedby` only lists parts that are rendered.
- FieldSet and FieldLegend use native fieldset and legend semantics.
Keyboard Interactions
| Key | Action |
|---|---|
| Tab | Moves through controls; clicking a label focuses its control. |
ARIA Attributes
- `aria-describedby` with description and error ids
- `aria-invalid` when invalid or an error is rendered
- `role="alert"` on errors
Reduced Motion
Field is layout only and has no motion of its own.
API Reference
Field
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
orientation | "vertical" | "horizontal" | "responsive" | - | vertical | Label and control layout. Responsive stacks on small screens. |
invalid | boolean | - | false | Marks the control aria-invalid and tints the label. |
disabled | boolean | - | false | Disables the control and dims the field. |
errors | Array<{ message?: string } | undefined> | No | - | Error objects (for example from a form library). Messages are de-duplicated. |
FieldControl
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
children | ReactElement | - | - | Single control. Receives the generated id, aria-describedby, aria-invalid and disabled. |
errors | Array<{ message?: string } | undefined> | No | - | Error objects (for example from a form library). Messages are de-duplicated. |
FieldError
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
errors | Array<{ message?: string } | undefined> | No | - | Messages from a form library; duplicates collapse. Renders nothing when empty. |
FieldLabel, FieldDescription, FieldContent, FieldTitle, FieldGroup, FieldSet, FieldLegend, FieldSeparator
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
className | string | - | - | Layout and typography parts. FieldLegend takes variant legend or label. |
errors | Array<{ message?: string } | undefined> | No | - | Error objects (for example from a form library). Messages are de-duplicated. |
Source
Import directly from the package or browse the source on GitHub. Click any file to view it.
Import
import { Field } from "@glinui/ui"Source Files
Dependencies
@glinui/ui@radix-ui/react-slotclass-variance-authorityGenerated API Snapshot
Beta
Generated API Snapshot
BetaAuto-extracted from TypeScript source in packages/ui/src/components/field.tsx. This section is in beta and may lag behind hand-curated docs. Regenerate with pnpm --filter @glinui/docs api:generate.
Generated: 2026-10-08T01:41:21.546Z · Full index: /docs/api-metadata
Primary Props Type
FieldProps
FieldErrorProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
errors | Array<{ message?: string } | undefined> | No | - | Error objects (for example from a form library). Messages are de-duplicated. |
FieldLabelProps
No explicit fields extracted for this props type.
FieldLegendProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
variant | "legend" | "label" | No | "legend" | - |
FieldProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
disabled | boolean | No | false | Marks the field disabled. |
invalid | boolean | No | false | Marks the field invalid and wires aria-invalid onto its control. |
orientation | "vertical" | "horizontal" | "responsive" | No | "vertical" | Variant option from fieldVariants. |