Field
Flexible field container that arranges label and content in various orientations.
Provides auto-generated IDs to child FieldError and FieldDescription components
for aria-describedby linking.
Usage
import { Field, fieldAnatomy, FieldContent, FieldDescription, FieldError, FieldGroup, fieldGroupAnatomy, FieldLabel, fieldVariants, useFieldIds } from "@desk/ui/components/field";Best practices
Set
invalidon theField, not on each control — it cascadesaria-invalidto descendantInput/InputGroupand turns theFieldLabeldestructive.Compose the documented parts (
FieldLabel,FieldContent,FieldError,FieldDescription) so generated ids wirearia-describedbyautomatically.Use
orientation="responsive"for a label-beside-control that collapses to stacked on mobile, rather than duplicating the field per breakpoint.
Props
Field
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "responsive" | null | undefined | ||
| invalid | boolean | Marks the field invalid and cascades aria-invalid to descendant inputs. |
FieldError
| Prop | Type | Default | Description |
|---|---|---|---|
| errors | ({ message?: string; } | undefined)[] |
Also exports
- const
fieldAnatomy - component
FieldContent - component
FieldDescription - component
FieldGroup - const
fieldGroupAnatomy - component
FieldLabel - const
fieldVariants - const
useFieldIds
Anatomy
Field
fieldForm field container with label, input, and feedback
FieldLabel
field-labelAccessible label for the field
FieldContent
field-contentContainer for input and messages
FieldDescription
field-descriptionHelper text or instructions
FieldError
field-errorValidation error messages
Composition
Builds on
Used by