Skip to content

Field

Field wraps a form control with a label, optional description, and error message. Use for all labeled form controls to ensure consistent layout and accessibility.

Code
<FieldGroup>
<Field>
<FieldLabel htmlFor="email">Email</FieldLabel>
<Input id="email" type="email" placeholder="you@example.com" />
<FieldDescription>We&apos;ll never share your email.</FieldDescription>
</Field>
<Field>
<FieldLabel htmlFor="password">Password</FieldLabel>
<Input id="password" type="password" />
<FieldError>Password must be at least 8 characters.</FieldError>
</Field>
</FieldGroup>

Connect descriptions and errors with aria-describedby, and set aria-invalid when the control is invalid.

Code
<Field>
<FieldLabel htmlFor="account-email">Email</FieldLabel>
<Input
id="account-email"
type="email"
aria-invalid="true"
aria-describedby="account-email-error"
/>
<FieldError id="account-email-error">Enter a valid email address.</FieldError>
</Field>
Code
<FieldGroup>
<Field orientation="horizontal">
<FieldLabel htmlFor="h-email">Email</FieldLabel>
<Input id="h-email" type="email" placeholder="you@example.com" />
</Field>
<Field orientation="horizontal">
<FieldLabel htmlFor="h-name">Name</FieldLabel>
<Input id="h-name" placeholder="Your name" />
</Field>
</FieldGroup>
Code
<FieldSet>
<FieldLegend className="tw:text-base tw:font-medium">
Notifications
</FieldLegend>
<FieldGroup className="tw:gap-3">
<Field orientation="horizontal">
<Checkbox id="email-notif" />
<FieldLabel htmlFor="email-notif">Email notifications</FieldLabel>
</Field>
<Field orientation="horizontal">
<Checkbox id="sms-notif" />
<FieldLabel htmlFor="sms-notif">SMS notifications</FieldLabel>
</Field>
</FieldGroup>
</FieldSet>

Use FieldContent when a checkbox or radio option needs a title plus supporting description.

Code
<Field orientation="horizontal">
<Checkbox id="marketing" />
<FieldLabel htmlFor="marketing">
<FieldContent>
<FieldTitle>Email marketing</FieldTitle>
<FieldDescription>Receive campaign updates.</FieldDescription>
</FieldContent>
</FieldLabel>
</Field>
Code
<FieldSet>
<FieldLegend className="tw:text-base tw:font-medium">
Fulfillment speed
</FieldLegend>
<RadioGroup defaultValue="standard">
<Field orientation="horizontal">
<RadioGroupItem id="standard" value="standard" />
<FieldLabel htmlFor="standard">Standard</FieldLabel>
</Field>
<Field orientation="horizontal">
<RadioGroupItem id="rush" value="rush" />
<FieldLabel htmlFor="rush">Rush</FieldLabel>
</Field>
<Field orientation="horizontal">
<RadioGroupItem id="scheduled" value="scheduled" />
<FieldLabel htmlFor="scheduled">Scheduled</FieldLabel>
</Field>
</RadioGroup>
</FieldSet>
NameType/Description
orientation = "vertical""horizontal" | "vertical" | "responsive" | null | undefined

No documented props

No documented props

NameType/Description
errors({ message?: string | undefined; } | undefined)[] | undefined

No documented props

No documented props

NameType/Description
variant = "legend""label" | "legend" | undefined

No documented props

No documented props

No documented props