Field
Compound form primitives — labels, descriptions, errors, groups, and layouts that compose around any control with shared ids and invalid state.
Installation#
pnpm dlx shadcn@latest add @davinciui/fieldUsage#
Field is a compound family, not a single control. Field provides layout and shares an id plus invalid state through context; every other part — labels, titles, descriptions, separators, errors — is a focused primitive that composes around any control.
Field#
FieldGroup#
FieldSet#
Anatomy#
Form#
Input#
Textarea#
Select#
Slider#
Checkbox#
Radio#
Switch#
Choice Card#
Field Group#
RTL#
Responsive Layout#
Validation and Errors#
Composition#
Use the following composition to build a Field:
FieldSet
├── FieldLegend
└── FieldGroup
└── Field
├── FieldLabel
├── FieldContent
│ ├── FieldControl
│ └── FieldDescription
└── FieldErrorAPI Reference#
| Prop | Type | Default |
|---|---|---|
Field · orientationLayout direction; responsive stacks on mobile, rows on sm+. | "vertical" | "horizontal" | "responsive" | "vertical" |
Field · invalidError state shared with FieldError via context. | boolean | false |
FieldControlWraps one control; auto-wires id, aria-invalid, and aria-describedby. Explicit props win. | Component | — |
FieldLabel · htmlForDefaults to the FieldControl id — omit it when using FieldControl. | string | — |
FieldError · errorsError messages; renders a list when more than one. | string[] | — |
FieldError · forceShowShow regardless of Field invalid state. | boolean | false |
FieldError · showIconLeading alert icon — errors never rely on color alone. | boolean | true |
FieldSetNative fieldset grouping with border. | fieldset element | — |
FieldLegendCaption for a FieldSet. | legend element | — |
FieldGroupVertical stack of fields with even spacing. | div | — |
FieldContentFlexible label/description wrapper for horizontal rows. | div | — |
FieldLabelControl label — pair htmlFor with the control id. | label element | — |
FieldTitleSection title inside groups and choice sets. | div | — |
FieldDescriptionHint text with a stable context id for aria-describedby. | p element | — |
FieldSeparatorLabeled divider between field sections. | div | — |
Accessibility#
FieldControl wires a child control's id, aria-invalid, and aria-describedby to the Field-generated description and error ids; FieldLabel falls back to that id. FieldError renders role='alert' with an icon, and FieldSeparator exposes role='separator'. FieldSet uses native fieldset and legend.
Motion#
Field is a static layout primitive with no animation; its parts only apply spacing, borders, and typography. No transitions are defined and reduced-motion handling is unnecessary.
Accessibility#
Pair every control with FieldLabel htmlFor matching the control's id — or skip both and wrap the control in FieldControl, which wires id, aria-invalid, and aria-describedby (description + error ids) automatically. Errors render with role="alert" and a leading icon, so assistive technology announces them immediately and sighted users never rely on color alone.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

