---
title: "Field"
description: "Combine labels, controls, and help text to compose accessible form fields and grouped inputs."
component: true
---

```tsx
import { For } from "solid-js"

import { Button } from "~/components/ui/button"
import { Checkbox } from "~/components/ui/checkbox"
import {
  Field,
  FieldDescription,
  FieldGroup,
  FieldLabel,
  FieldLegend,
  FieldSeparator,
  FieldSet
} from "~/components/ui/field"
import { Input } from "~/components/ui/input"
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue
} from "~/components/ui/select"
import { Textarea } from "~/components/ui/textarea"

const months = [
  "01",
  "02",
  "03",
  "04",
  "05",
  "06",
  "07",
  "08",
  "09",
  "10",
  "11",
  "12"
]
const years = ["2024", "2025", "2026", "2027", "2028", "2029"]

export default function FieldDemo() {
  return (
    <div class="w-full max-w-md">
      <form>
        <FieldGroup>
          <FieldSet>
            <FieldLegend>Payment Method</FieldLegend>
            <FieldDescription>
              All transactions are secure and encrypted
            </FieldDescription>
            <FieldGroup>
              <Field>
                <FieldLabel for="checkout-card-name">Name on Card</FieldLabel>
                <Input
                  id="checkout-card-name"
                  placeholder="Evil Rabbit"
                  required
                />
              </Field>
              <Field>
                <FieldLabel for="checkout-card-number">Card Number</FieldLabel>
                <Input
                  id="checkout-card-number"
                  placeholder="1234 5678 9012 3456"
                  required
                />
                <FieldDescription>
                  Enter your 16-digit card number
                </FieldDescription>
              </Field>
              <div class="grid grid-cols-3 gap-4">
                <Field>
                  <FieldLabel for="checkout-exp-month">Month</FieldLabel>
                  <Select<string> placeholder="MM">
                    <SelectTrigger
                      aria-label="MM"
                      class="w-full"
                      id="checkout-exp-month"
                    >
                      <SelectValue />
                    </SelectTrigger>
                    <SelectContent>
                      <For each={months}>
                        {(option) => (
                          <SelectItem value={option}>{option}</SelectItem>
                        )}
                      </For>
                    </SelectContent>
                  </Select>
                </Field>
                <Field>
                  <FieldLabel for="checkout-exp-year">Year</FieldLabel>
                  <Select<string> placeholder="YYYY">
                    <SelectTrigger
                      aria-label="YYYY"
                      class="w-full"
                      id="checkout-exp-year"
                    >
                      <SelectValue />
                    </SelectTrigger>
                    <SelectContent>
                      <For each={years}>
                        {(option) => (
                          <SelectItem value={option}>{option}</SelectItem>
                        )}
                      </For>
                    </SelectContent>
                  </Select>
                </Field>
                <Field>
                  <FieldLabel for="checkout-cvv">CVV</FieldLabel>
                  <Input id="checkout-cvv" placeholder="123" required />
                </Field>
              </div>
            </FieldGroup>
          </FieldSet>
          <FieldSeparator />
          <FieldSet>
            <FieldLegend>Billing Address</FieldLegend>
            <FieldDescription>
              The billing address associated with your payment method
            </FieldDescription>
            <FieldGroup>
              <Field orientation="horizontal">
                <Checkbox id="checkout-same-as-shipping" defaultChecked />
                <FieldLabel class="font-normal" for="checkout-same-as-shipping">
                  Same as shipping address
                </FieldLabel>
              </Field>
            </FieldGroup>
          </FieldSet>

          <FieldSet>
            <FieldGroup>
              <Field>
                <FieldLabel for="checkout-comments">Comments</FieldLabel>
                <Textarea
                  class="resize-none"
                  id="checkout-comments"
                  placeholder="Add any additional comments"
                />
              </Field>
            </FieldGroup>
          </FieldSet>

          <Field orientation="horizontal">
            <Button type="submit">Submit</Button>
            <Button type="button" variant="outline">
              Cancel
            </Button>
          </Field>
        </FieldGroup>
      </form>
    </div>
  )
}
```

## Installation

<CodeTabs>

<TabsList>
  <TabsTrigger value="cli">Command</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>

<TabsContent value="cli">

```bash
npx solidui-cli@latest add field
```

</TabsContent>

<TabsContent value="manual">

<Steps class="mb-0 pt-2">

<Step>Install the following dependencies:</Step>

```bash
npm install class-variance-authority
```

<Step>Install the required Solid UI dependencies:</Step>

```bash
npx solidui-cli@latest add label separator
```

<Step>Copy and paste the following code into your project.</Step>

```tsx title="components/ui/field.tsx"
import { type ComponentProps, type JSX } from "@solidjs/web"
import { cva, type VariantProps } from "class-variance-authority"
import { createMemo, For, omit, Show } from "solid-js"

import { cn } from "~/lib/utils"
import { Label } from "~/components/ui/label"
import { Separator } from "~/components/ui/separator"

type FieldSetProps = ComponentProps<"fieldset"> & {
  class?: string | undefined
}

const FieldSet = (props: FieldSetProps) => (
  <fieldset
    data-slot="field-set"
    {...props}
    class={cn("gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 flex flex-col", props.class)}
  />
)

type FieldLegendProps = ComponentProps<"legend"> & {
  class?: string | undefined
  variant?: "legend" | "label"
}

const FieldLegend = (props: FieldLegendProps) => {
  const others = omit(props, "class", "variant")
  return (
    <legend
      data-slot="field-legend"
      data-variant={props.variant ?? "legend"}
      class={cn("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base", props.class)}
      {...others}
    />
  )
}

type FieldGroupProps = ComponentProps<"div"> & {
  class?: string | undefined
}

const FieldGroup = (props: FieldGroupProps) => (
  <div
    data-slot="field-group"
    {...props}
    class={cn(
      "group/field-group gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4 @container/field-group flex w-full flex-col",
      props.class
    )}
  />
)

const fieldVariants = cva("group/field gap-2 data-[invalid=true]:text-destructive flex w-full", {
  variants: {
    orientation: {
      vertical:
        "flex-col [&>.sr-only]:w-auto [&>:where(:not([popover],[data-presentation]))]:w-full",
      horizontal:
        "flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
      responsive:
        "flex-col @md/field-group:flex-row @md/field-group:items-center @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto [&>:where(:not([popover],[data-presentation]))]:w-full @md/field-group:[&>:where(:not([popover],[data-presentation]))]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
    }
  },
  defaultVariants: {
    orientation: "vertical"
  }
})

type FieldProps = ComponentProps<"div"> &
  VariantProps<typeof fieldVariants> & {
    class?: string | undefined
  }

const Field = (props: FieldProps) => {
  const others = omit(props, "class", "orientation")
  return (
    <div
      role="group"
      data-slot="field"
      data-orientation={props.orientation ?? "vertical"}
      class={cn(fieldVariants({ orientation: props.orientation }), props.class)}
      {...others}
    />
  )
}

type FieldContentProps = ComponentProps<"div"> & {
  class?: string | undefined
}

const FieldContent = (props: FieldContentProps) => (
  <div
    data-slot="field-content"
    {...props}
    class={cn(
      "group/field-content gap-0.5 flex flex-1 flex-col leading-snug",
      props.class
    )}
  />
)

type FieldLabelProps = ComponentProps<typeof Label> & {
  class?: string | undefined
}

const FieldLabel = (props: FieldLabelProps) => (
  <Label
    data-slot="field-label"
    {...props}
    class={cn(
      "group/field-label peer/field-label gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit leading-snug",
      "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
      props.class
    )}
  />
)

type FieldTitleProps = ComponentProps<"div"> & {
  class?: string | undefined
}

const FieldTitle = (props: FieldTitleProps) => (
  <div
    data-slot="field-label"
    {...props}
    class={cn(
      "gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50 flex w-fit items-center leading-snug",
      props.class
    )}
  />
)

type FieldDescriptionProps = ComponentProps<"p"> & {
  class?: string | undefined
}

const FieldDescription = (props: FieldDescriptionProps) => (
  <p
    data-slot="field-description"
    {...props}
    class={cn(
      "text-left text-sm text-muted-foreground [[data-variant=legend]+&]:-mt-1.5 leading-normal font-normal group-has-data-[orientation=horizontal]/field:text-balance",
      "last:mt-0 nth-last-2:-mt-1",
      "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
      props.class
    )}
  />
)

type FieldSeparatorProps = ComponentProps<"div"> & {
  class?: string | undefined
  children?: JSX.Element
}

const FieldSeparator = (props: FieldSeparatorProps) => {
  const others = omit(props, "class", "children")
  return (
    <div
      data-slot="field-separator"
      data-content={!!props.children}
      class={cn("-my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2 relative", props.class)}
      {...others}
    >
      <Separator class="absolute inset-0 top-1/2" />
      <Show when={props.children}>
        <span
          class="px-2 text-muted-foreground relative mx-auto block w-fit bg-background"
          data-slot="field-separator-content"
        >
          {props.children}
        </span>
      </Show>
    </div>
  )
}

type FieldErrorProps = ComponentProps<"div"> & {
  class?: string | undefined
  children?: JSX.Element
  errors?: ReadonlyArray<
    | {
        message?: string
      }
    | undefined
  >
}

const FieldError = (props: FieldErrorProps) => {
  const others = omit(props, "class", "children", "errors")
  const content = createMemo(() => {
    if (props.children) {
      return props.children
    }
    if (!props.errors?.length) {
      return null
    }
    const uniqueErrors = [
      ...new Map(props.errors.map((error) => [error?.message, error])).values()
    ]
    if (uniqueErrors.length === 1) {
      return uniqueErrors[0]?.message
    }
    return (
      <ul class="ml-4 flex list-disc flex-col gap-1">
        <For each={uniqueErrors}>
          {(error) => (
            <Show when={error?.message}>
              {(message) => <li>{message()}</li>}
            </Show>
          )}
        </For>
      </ul>
    )
  })
  return (
    <Show when={content()}>
      <div
        role="alert"
        data-slot="field-error"
        class={cn("text-sm text-destructive font-normal", props.class)}
        {...others}
      >
        {content()}
      </div>
    </Show>
  )
}

export {
  Field,
  FieldContent,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel,
  FieldLegend,
  FieldSeparator,
  FieldSet,
  FieldTitle,
  fieldVariants,
  type FieldContentProps,
  type FieldDescriptionProps,
  type FieldErrorProps,
  type FieldGroupProps,
  type FieldLabelProps,
  type FieldLegendProps,
  type FieldProps,
  type FieldSeparatorProps,
  type FieldSetProps,
  type FieldTitleProps
}
```

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</CodeTabs>

## Usage

```tsx showLineNumbers
import {
  Field,
  FieldDescription,
  FieldError,
  FieldGroup,
  FieldLabel,
  FieldLegend,
  FieldSet
} from "~/components/ui/field"
```

```tsx showLineNumbers
<FieldSet>
  <FieldLegend>Profile</FieldLegend>
  <FieldDescription>This appears on invoices and emails.</FieldDescription>
  <FieldGroup>
    <Field>
      <FieldLabel for="name">Full name</FieldLabel>
      <input id="name" autocomplete="off" placeholder="Evil Rabbit" />
      <FieldDescription>This appears on invoices and emails.</FieldDescription>
    </Field>
    <Field>
      <FieldLabel for="username">Username</FieldLabel>
      <input id="username" autocomplete="off" aria-invalid="true" />
      <FieldError>Choose another username.</FieldError>
    </Field>
    <Field orientation="horizontal">
      <input id="newsletter" type="checkbox" />
      <FieldLabel for="newsletter">Subscribe to the newsletter</FieldLabel>
    </Field>
  </FieldGroup>
</FieldSet>
```

## Composition

### Field

A single control with label, helper text, and validation.

```text
Field
├── FieldLabel
├── Input / Textarea / Switch / Select
├── FieldDescription
└── FieldError
```

### FieldGroup

Related fields in one group. Use `FieldSeparator` between sections when needed.

```text
FieldGroup
├── Field
│   ├── FieldLabel
│   ├── Input / Textarea / Switch / Select
│   ├── FieldDescription
│   └── FieldError
├── FieldSeparator
└── Field
    ├── FieldLabel
    └── Input / Textarea / Switch / Select
```

### FieldSet

Semantic grouping with a legend and description, usually containing a `FieldGroup`.

```text
FieldSet
├── FieldLegend
├── FieldDescription
└── FieldGroup
    ├── Field
    │   ├── FieldLabel
    │   ├── Input / Textarea / Switch / Select
    │   ├── FieldDescription
    │   └── FieldError
    └── Field
        ├── FieldLabel
        └── Input / Textarea / Switch / Select
```

`FieldContent` and `FieldTitle` are local helpers you can use when horizontal or responsive layouts need extra structure around labels, descriptions, and errors.

## Anatomy

The `Field` family is designed for composing accessible forms. A typical field is structured as follows:

```tsx showLineNumbers
<Field>
  <FieldLabel for="input-id">Label</FieldLabel>
  {/* Input, Select, Switch, etc. */}
  <FieldDescription>Optional helper text.</FieldDescription>
  <FieldError>Validation message.</FieldError>
</Field>
```

- `Field` is the core wrapper for a single field.
- `FieldContent` is a flex column that groups labels, descriptions, and errors.
- Wrap related fields with `FieldGroup`, and use `FieldSet` with `FieldLegend` for semantic grouping.

## Form

`Field` works with native form submission and with Solid form libraries. Pass `name`, `required`, and validation attributes to the controls, and render `FieldError` for messages.

## Input

```tsx
import {
  Field,
  FieldDescription,
  FieldGroup,
  FieldLabel,
  FieldSet
} from "~/components/ui/field"
import { Input } from "~/components/ui/input"

export default function FieldInput() {
  return (
    <div class="w-full max-w-md">
      <FieldSet>
        <FieldGroup>
          <Field>
            <FieldLabel for="field-input-username">Username</FieldLabel>
            <Input
              id="field-input-username"
              placeholder="Max Leiter"
              type="text"
            />
            <FieldDescription>
              Choose a unique username for your account.
            </FieldDescription>
          </Field>
          <Field>
            <FieldLabel for="field-input-password">Password</FieldLabel>
            <FieldDescription>
              Must be at least 8 characters long.
            </FieldDescription>
            <Input
              id="field-input-password"
              placeholder="••••••••"
              type="password"
            />
          </Field>
        </FieldGroup>
      </FieldSet>
    </div>
  )
}
```

## Textarea

```tsx
import {
  Field,
  FieldDescription,
  FieldGroup,
  FieldLabel,
  FieldSet
} from "~/components/ui/field"
import { Textarea } from "~/components/ui/textarea"

export default function FieldTextarea() {
  return (
    <div class="w-full max-w-md">
      <FieldSet>
        <FieldGroup>
          <Field>
            <FieldLabel for="field-textarea-feedback">Feedback</FieldLabel>
            <Textarea
              id="field-textarea-feedback"
              placeholder="Your feedback helps us improve..."
              rows={4}
            />
            <FieldDescription>
              Share your thoughts about our service.
            </FieldDescription>
          </Field>
        </FieldGroup>
      </FieldSet>
    </div>
  )
}
```

## Select

```tsx
import { For } from "solid-js"

import { Field, FieldDescription, FieldLabel } from "~/components/ui/field"
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue
} from "~/components/ui/select"

type Department = {
  label: string
  value: string
}

const departments: Department[] = [
  { label: "Engineering", value: "engineering" },
  { label: "Design", value: "design" },
  { label: "Marketing", value: "marketing" },
  { label: "Sales", value: "sales" },
  { label: "Customer Support", value: "support" },
  { label: "Human Resources", value: "hr" },
  { label: "Finance", value: "finance" },
  { label: "Operations", value: "operations" }
]

export default function FieldSelect() {
  return (
    <div class="w-full max-w-md">
      <Field>
        <FieldLabel for="field-select-department">Department</FieldLabel>
        <Select<Department>
          itemToLabel={(option) => String(option["label"])}
          itemToValue={(option) => String(option["value"])}

          placeholder="Choose department"
        >
          <SelectTrigger
            aria-label="Choose department"
            class="w-full"
            id="field-select-department"
          >
            <SelectValue />
          </SelectTrigger>
          <SelectContent>
            <For each={departments}>
              {(option) => (
                <SelectItem value={option} label={option["label"]}>
                  {option.label}
                </SelectItem>
              )}
            </For>
          </SelectContent>
        </Select>
        <FieldDescription>
          Select your department or area of work.
        </FieldDescription>
      </Field>
    </div>
  )
}
```

## Slider

```tsx
import { createSignal } from "solid-js"

import { Field, FieldDescription, FieldTitle } from "~/components/ui/field"
import { Slider } from "~/components/ui/slider"

export default function FieldSlider() {
  const [value, setValue] = createSignal([200, 800])

  return (
    <div class="w-full max-w-md">
      <Field>
        <FieldTitle>Price Range</FieldTitle>
        <FieldDescription>
          Set your budget range ($
          <span class="font-medium tabular-nums">{value()[0]}</span> -{" "}
          <span class="font-medium tabular-nums">{value()[1]}</span>).
        </FieldDescription>
        <Slider
          aria-label="Price Range"
          class="mt-2 w-full"
          max={1000}
          min={0}
          onValueChange={setValue}
          step={10}
          value={value()}
        />
      </Field>
    </div>
  )
}
```

## Fieldset

```tsx
import {
  Field,
  FieldDescription,
  FieldGroup,
  FieldLabel,
  FieldLegend,
  FieldSet
} from "~/components/ui/field"
import { Input } from "~/components/ui/input"

export default function FieldFieldset() {
  return (
    <div class="w-full max-w-sm">
      <FieldSet>
        <FieldLegend>Address Information</FieldLegend>
        <FieldDescription>
          We need your address to deliver your order.
        </FieldDescription>
        <FieldGroup>
          <Field>
            <FieldLabel for="field-fieldset-street">Street Address</FieldLabel>
            <Input
              id="field-fieldset-street"
              placeholder="123 Main St"
              type="text"
            />
          </Field>
          <div class="grid grid-cols-2 gap-4">
            <Field>
              <FieldLabel for="field-fieldset-city">City</FieldLabel>
              <Input
                id="field-fieldset-city"
                placeholder="New York"
                type="text"
              />
            </Field>
            <Field>
              <FieldLabel for="field-fieldset-zip">Postal Code</FieldLabel>
              <Input id="field-fieldset-zip" placeholder="90502" type="text" />
            </Field>
          </div>
        </FieldGroup>
      </FieldSet>
    </div>
  )
}
```

## Checkbox

```tsx
import { Checkbox } from "~/components/ui/checkbox"
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldGroup,
  FieldLabel,
  FieldLegend,
  FieldSeparator,
  FieldSet
} from "~/components/ui/field"

export default function FieldCheckbox() {
  return (
    <div class="w-full max-w-xs">
      <FieldGroup>
        <FieldSet>
          <FieldLegend variant="label">
            Show these items on the desktop
          </FieldLegend>
          <FieldDescription>
            Select the items you want to show on the desktop.
          </FieldDescription>
          <FieldGroup class="gap-3">
            <Field orientation="horizontal">
              <Checkbox id="finder-pref-hard-disks" />
              <FieldLabel class="font-normal" for="finder-pref-hard-disks">
                Hard disks
              </FieldLabel>
            </Field>
            <Field orientation="horizontal">
              <Checkbox id="finder-pref-external-disks" />
              <FieldLabel class="font-normal" for="finder-pref-external-disks">
                External disks
              </FieldLabel>
            </Field>
            <Field orientation="horizontal">
              <Checkbox id="finder-pref-cds-dvds" />
              <FieldLabel class="font-normal" for="finder-pref-cds-dvds">
                CDs, DVDs, and iPods
              </FieldLabel>
            </Field>
            <Field orientation="horizontal">
              <Checkbox id="finder-pref-servers" />
              <FieldLabel class="font-normal" for="finder-pref-servers">
                Connected servers
              </FieldLabel>
            </Field>
          </FieldGroup>
        </FieldSet>
        <FieldSeparator />
        <Field orientation="horizontal">
          <Checkbox defaultChecked id="finder-pref-sync-folders" />
          <FieldContent>
            <FieldLabel for="finder-pref-sync-folders">
              Sync Desktop & Documents folders
            </FieldLabel>
            <FieldDescription>
              Your Desktop & Documents folders are synced with iCloud Drive, so
              you can access them from other devices.
            </FieldDescription>
          </FieldContent>
        </Field>
      </FieldGroup>
    </div>
  )
}
```

## Radio

```tsx
import {
  Field,
  FieldDescription,
  FieldLabel,
  FieldLegend,
  FieldSet
} from "~/components/ui/field"
import { RadioGroup, RadioGroupItem } from "~/components/ui/radio-group"

export default function FieldRadio() {
  return (
    <FieldSet class="w-full max-w-xs">
      <FieldLegend variant="label">Subscription Plan</FieldLegend>
      <FieldDescription>
        Yearly and lifetime plans offer significant savings.
      </FieldDescription>
      <RadioGroup defaultValue="monthly">
        <Field orientation="horizontal">
          <RadioGroupItem value="monthly" id="plan-monthly" />
          <FieldLabel for="plan-monthly" class="font-normal">
            Monthly ($9.99/month)
          </FieldLabel>
        </Field>
        <Field orientation="horizontal">
          <RadioGroupItem value="yearly" id="plan-yearly" />
          <FieldLabel for="plan-yearly" class="font-normal">
            Yearly ($99.99/year)
          </FieldLabel>
        </Field>
        <Field orientation="horizontal">
          <RadioGroupItem value="lifetime" id="plan-lifetime" />
          <FieldLabel for="plan-lifetime" class="font-normal">
            Lifetime ($299.99)
          </FieldLabel>
        </Field>
      </RadioGroup>
    </FieldSet>
  )
}
```

## Switch

```tsx
import { Field, FieldLabel } from "~/components/ui/field"
import { Switch } from "~/components/ui/switch"

export default function FieldSwitch() {
  return (
    <Field orientation="horizontal" class="w-fit">
      <FieldLabel for="2fa">Multi-factor authentication</FieldLabel>
      <Switch id="2fa" />
    </Field>
  )
}
```

## Choice Card

Wrap each horizontal `Field` in a `FieldLabel` to make the whole choice card selectable. This example uses `RadioGroupItem`.

```tsx
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldGroup,
  FieldLabel,
  FieldLegend,
  FieldSet,
  FieldTitle
} from "~/components/ui/field"
import { RadioGroup, RadioGroupItem } from "~/components/ui/radio-group"

export default function FieldChoiceCard() {
  return (
    <FieldGroup class="w-full max-w-xs">
      <FieldSet>
        <FieldLegend variant="label">Compute Environment</FieldLegend>
        <FieldDescription>
          Select the compute environment for your cluster.
        </FieldDescription>
        <RadioGroup defaultValue="kubernetes">
          <FieldLabel for="kubernetes-r2h">
            <Field orientation="horizontal">
              <FieldContent>
                <FieldTitle>Kubernetes</FieldTitle>
                <FieldDescription>
                  Run GPU workloads on a K8s cluster.
                </FieldDescription>
              </FieldContent>
              <RadioGroupItem value="kubernetes" id="kubernetes-r2h" />
            </Field>
          </FieldLabel>
          <FieldLabel for="vm-z4k">
            <Field orientation="horizontal">
              <FieldContent>
                <FieldTitle>Virtual Machine</FieldTitle>
                <FieldDescription>
                  Access a cluster to run GPU workloads.
                </FieldDescription>
              </FieldContent>
              <RadioGroupItem value="vm" id="vm-z4k" />
            </Field>
          </FieldLabel>
        </RadioGroup>
      </FieldSet>
    </FieldGroup>
  )
}
```

## Field Group

Stack `Field` components with `FieldGroup`. Add `FieldSeparator` to divide them.

```tsx
import { Checkbox } from "~/components/ui/checkbox"
import {
  Field,
  FieldDescription,
  FieldGroup,
  FieldLabel,
  FieldSeparator,
  FieldSet
} from "~/components/ui/field"

export default function FieldGroupExample() {
  return (
    <div class="w-full max-w-xs">
      <FieldGroup>
        <FieldSet>
          <FieldLabel>Responses</FieldLabel>
          <FieldDescription>
            Get notified when responses complete for longer requests, like
            research or image generation.
          </FieldDescription>
          <FieldGroup data-slot="checkbox-group">
            <Field orientation="horizontal">
              <Checkbox defaultChecked disabled id="field-group-push" />
              <FieldLabel class="font-normal" for="field-group-push">
                Push notifications
              </FieldLabel>
            </Field>
          </FieldGroup>
        </FieldSet>
        <FieldSeparator />
        <FieldSet>
          <FieldLabel>Tasks</FieldLabel>
          <FieldDescription>
            Get notified when tasks you created have updates.{" "}
            <a href="#">Manage tasks</a>
          </FieldDescription>
          <FieldGroup data-slot="checkbox-group">
            <Field orientation="horizontal">
              <Checkbox id="field-group-push-tasks" />
              <FieldLabel class="font-normal" for="field-group-push-tasks">
                Push notifications
              </FieldLabel>
            </Field>
            <Field orientation="horizontal">
              <Checkbox id="field-group-email-tasks" />
              <FieldLabel class="font-normal" for="field-group-email-tasks">
                Email notifications
              </FieldLabel>
            </Field>
          </FieldGroup>
        </FieldSet>
      </FieldGroup>
    </div>
  )
}
```

## Responsive Layout

- **Vertical fields:** Default orientation stacks label, control, and helper text—ideal for mobile-first layouts.
- **Horizontal fields:** Set `orientation="horizontal"` on `Field` to align the label and control side-by-side. Pair with `FieldContent` to keep descriptions aligned.
- **Responsive fields:** Set `orientation="responsive"` for automatic column layouts inside container-aware parents. Apply `@container/field-group` classes on `FieldGroup` to switch orientations at specific breakpoints.

```tsx
import { Button } from "~/components/ui/button"
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldGroup,
  FieldLabel,
  FieldLegend,
  FieldSet
} from "~/components/ui/field"
import { Input } from "~/components/ui/input"

export default function FieldResponsive() {
  return (
    <div class="w-full max-w-lg">
      <form>
        <FieldSet>
          <FieldLegend>Profile</FieldLegend>
          <FieldDescription>Fill in your profile information.</FieldDescription>
          <FieldGroup>
            <Field orientation="responsive">
              <FieldContent>
                <FieldLabel for="name">Name</FieldLabel>
                <FieldDescription>
                  Provide your full name for identification
                </FieldDescription>
              </FieldContent>
              <Input id="name" placeholder="Evil Rabbit" required />
            </Field>
            <Field orientation="responsive">
              <Button type="submit">Submit</Button>
              <Button type="button" variant="outline">
                Cancel
              </Button>
            </Field>
          </FieldGroup>
        </FieldSet>
      </form>
    </div>
  )
}
```

## Validation and Errors

- Add `data-invalid` to `Field` to switch the entire block into an error state.
- Add `aria-invalid` on the control itself for assistive technologies.
- Render `FieldError` after the control or inside `FieldContent` to keep errors aligned.

```tsx showLineNumbers /data-invalid/ /aria-invalid/
<Field data-invalid>
  <FieldLabel for="email">Email</FieldLabel>
  <Input id="email" type="email" aria-invalid />
  <FieldError>Enter a valid email address.</FieldError>
</Field>
```

## Accessibility

- `FieldSet` and `FieldLegend` keep related controls grouped for keyboard and assistive tech users.
- `Field` renders `role="group"` so nested controls can inherit labels and descriptions.
- Use `FieldSeparator` sparingly so section boundaries stay clear for screen readers.

## API Reference

### FieldSet

Container that renders a semantic `fieldset` with spacing presets.

| Prop    | Type     | Default |
| ------- | -------- | ------- |
| `class` | `string` | -       |

```tsx
<FieldSet>
  <FieldLegend>Delivery</FieldLegend>
  <FieldGroup>{/* Fields */}</FieldGroup>
</FieldSet>
```

### FieldLegend

Legend element for a `FieldSet`. Switch to the `label` variant to align with label sizing.

| Prop      | Type                  | Default    |
| --------- | --------------------- | ---------- |
| `variant` | `"legend" \| "label"` | `"legend"` |
| `class`   | `string`              | -          |

```tsx
<FieldLegend variant="label">Notification Preferences</FieldLegend>
```

### FieldGroup

Layout wrapper that stacks `Field` components and enables container queries for responsive orientations.

| Prop    | Type     | Default |
| ------- | -------- | ------- |
| `class` | `string` | -       |

```tsx
<FieldGroup class="@container/field-group flex flex-col gap-6">
  <Field>{/* ... */}</Field>
  <Field>{/* ... */}</Field>
</FieldGroup>
```

### Field

The core wrapper for a single field. Provides orientation control and invalid-state styling.

| Prop           | Type                                         | Default      |
| -------------- | -------------------------------------------- | ------------ |
| `orientation`  | `"vertical" \| "horizontal" \| "responsive"` | `"vertical"` |
| `class`        | `string`                                     | -            |
| `data-invalid` | `boolean`                                    | -            |

```tsx
<Field orientation="horizontal">
  <FieldLabel for="remember">Remember me</FieldLabel>
  <Checkbox id="remember" />
</Field>
```

### FieldContent

Flex column that groups control descriptions when label and control are arranged side by side.

| Prop    | Type     | Default |
| ------- | -------- | ------- |
| `class` | `string` | -       |

```tsx
<Field>
  <Checkbox id="notifications" />
  <FieldContent>
    <FieldLabel for="notifications">Notifications</FieldLabel>
    <FieldDescription>Email, SMS, and push options.</FieldDescription>
  </FieldContent>
</Field>
```

### FieldLabel

Label styled for direct controls and nested field-card layouts.

| Prop    | Type     | Default |
| ------- | -------- | ------- |
| `class` | `string` | -       |

```tsx
<FieldLabel for="email">Email</FieldLabel>
```

### FieldTitle

Renders a title with label styling inside `FieldContent`.

| Prop    | Type     | Default |
| ------- | -------- | ------- |
| `class` | `string` | -       |

```tsx
<FieldContent>
  <FieldTitle>Enable Touch ID</FieldTitle>
  <FieldDescription>Unlock your device faster.</FieldDescription>
</FieldContent>
```

### FieldDescription

Helper text slot that balances long lines in horizontal layouts.

| Prop    | Type     | Default |
| ------- | -------- | ------- |
| `class` | `string` | -       |

```tsx
<FieldDescription>We never share your email with anyone.</FieldDescription>
```

### FieldSeparator

Visual divider to separate sections inside a `FieldGroup`. Accepts optional inline content.

| Prop    | Type     | Default |
| ------- | -------- | ------- |
| `class` | `string` | -       |

```tsx
<FieldSeparator>Or continue with</FieldSeparator>
```

### FieldError

Accessible error container that accepts children or an `errors` array, including validator issues.

| Prop     | Type                                               | Default |
| -------- | -------------------------------------------------- | ------- |
| `errors` | `ReadonlyArray<{ message?: string } \| undefined>` | -       |
| `class`  | `string`                                           | -       |

```tsx
<FieldError errors={errors.username} />
```

When the `errors` array contains multiple messages, `FieldError` renders a list automatically.

`FieldError` also accepts issues produced by any validator that implements [Standard Schema](https://standardschema.dev/), including Zod, Valibot, and ArkType. Pass the `issues` array from the schema result directly to render a unified error list across libraries.
