Field

Form layout: a label, the control, a description and errors, in groups and fieldsets.

@cupertinoui/fieldRegistry JSON

Installation

pnpm dlx shadcn@latest add @cupertinoui/field

The first install also adds the macOS theme. See Installation to set up the registry.

Usage

import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"

<Field>
  <FieldLabel htmlFor="name">Name</FieldLabel>
  <Input id="name" />
  <FieldDescription>As it appears on your Apple Account.</FieldDescription>
</Field>

API Reference

Every part forwards the props of the underlying element. The props below are the ones CupertinoUI adds or changes.

Field

PropTypeDescription
orientation"vertical" | "horizontal" | "responsive"
Default: "vertical"
Label above the control, beside it, or beside it on wide screens.
data-invalidbooleanColors the field red.
classNamestringExtra classes, merged with the component's own.

FieldError

PropTypeDescription
errors{ message?: string }[]Messages to list, e.g. from a form library.
classNamestringExtra classes, merged with the component's own.

FieldSet / FieldLegend / FieldGroup / FieldContent / FieldLabel / FieldTitle / FieldDescription / FieldSeparator

PropTypeDescription
classNamestringExtra classes, merged with the component's own.