---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Field

A form row that ties one control to its label, its description and its error line, as a settings row or a stacked form field, for React and Tailwind CSS. Free, MIT.

Free. Its export: `Field`.

## Try it: field

Turn the settings on and off by the switch, its label or Space: each change saves at once and the line under the list says so. Text alerts are refused and the switch goes back.

The save is a timer; the refusal is our own rule (the sample account has no phone number).

## Try it: field-avatar

Press the round avatar (or Tab to it and press Enter) and choose a picture: it shows at once and uploads for a moment. A file over 2 MB or not a picture is refused in the row; Remove puts the initials back.

The upload is a timer; the picture never leaves the page. The theme ships no picture chooser for this row: the avatar-as-button and its hidden file field are this example’s own composition.

## Try it: field-button

Press Export: the button is busy for a moment, then the row says the file is ready. Press Sign out: the other sessions end and the button switches off.

Both are timers: no file is made and no one is signed out.

## Try it: field-edit

Press the pencil to edit the address in place and Save: an address without an @, or lucia@fieldwork.test (in use), is refused under the field; a good one is saved after a moment. Cancel or Escape leave it as it was; the focus returns to the pencil.

The save is a timer; the address in use is our own sample.

## Try it: field-icon

Press an icon to cycle it and type the name; Look puts the pairs in two settings rows or bare as a form’s title line. In the rows, switch row or column, the hairline, stacking on a phone (seen under 641 px) and invalid; disable them in either.

Nothing is saved; the picker cycles five icons instead of opening a list.

## Try it: field-select

Choose a start page or how names are shown: each choice saves at once (the line under the list says so) and the row’s description follows the name choice.

The save is a timer; the name is our own sample.

## Try it: field-stacked

Type a start and an end; switch the column to a row, add a description, disable the fields, mark the end invalid.

The times are not checked: "Invalid" only marks the end box.

## Try it: field-tile

Press a row’s words or its switch to turn it on; switch row or column, the hairline, stacking on a phone (seen under 641 px), disabled, the descriptions and the tiles.

Nothing is saved: the rows only say their state.

## When to use

- A form row that ties one control to its label, its description and its error line, as a settings row or a stacked form field.
- Also called: form field or form control.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Field on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.

```sh
npx shadcn@4.23.1 add @goop/trail-field
```

```text
Add the Goop Field to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { Field, FieldValue } from '@/components/ui/goop/field';
import { Card } from '@/components/ui/goop/card';
import { Switch } from '@/components/ui/goop/switch';
import { MultiSelect, MultiSelectItem } from '@/components/ui/goop/multi-select';

<Card variant="outline" asChild>
  <ul>
    <Field as="li" label="Weekly digest" description="A summary every Monday">
      {(control) => <Switch {...control} />}
    </Field>
    <Field as="li" label="Who takes part" description="Every group the study recruits from" stack="always">
      <MultiSelect defaultValue={['Clinic staff']} placeholder="Choose who takes part">
        <MultiSelectItem value="Clinic staff">Clinic staff</MultiSelectItem>
        <MultiSelectItem value="Night shift">Night shift</MultiSelectItem>
        <MultiSelectItem value="Patients">Patients</MultiSelectItem>
      </MultiSelect>
    </Field>
  </ul>
</Card>
```

- Fits: account, flow, settings, schedule (their recipes).
- Field is one piece: `label` and `description` are its props, with no label or description part to import, and a bare Field is a settings row (`orientation="horizontal"`); a form's label over its control is `orientation="vertical"`. A row's control is one line tall: the row centres its words against it, so a tall control (a RadioGroup, a column of checkboxes) leaves the label floating at the row's middle, far from the first option on a wide page. Put a choice of a few short options in a Select in the row; put options that need their own words (a size and its price) in `orientation="vertical"` (the label over the group, the group named by `aria-label`), or under a heading of their own.
- More on where it goes: field--options.md
- height, width, padding, gap, background, text: add no class for these.

## API reference

### Options

- `orientation: horizontal | vertical = horizontal`

- Each option with its sentence: field--options.md
- Another example of it: field-error.md, input-group.md, rating.md, textarea.md

### Parts

- `FieldValue` — The row's current value, shown before its control (an address before its edit button)

- Class recipes (cva): fieldVariants (Field)
- data-slot values (to select a part by): field, field-content, field-control, field-description, field-label, field-media, field-value

### Field: every option

```tsx
import { Field } from '@/components/ui/goop/field';
```

### Compose

- A vertical field has no inside of its own: in a list of rows give the row `stack="always"` instead; a group that is no Field (a ChoiceGroup) is held in an `li` with `p-4 max-narrow:px-2.5`.
- FieldValue: A value with its edit button: `<Field label="Email">{(control) => (<><FieldValue>sam@example.com</FieldValue> <IconButton … {...control}>…</IconButton></>)}</Field>`. A value alone (a read-only fact) takes the control's id: `<FieldValue id={control.id}>`.

### Options

- orientation: horizontal (default), vertical
- as?: 'div' | 'li' = 'div' — `li` makes the row an item of its list (a settings list's `ul`); a `div` by default.
- ref?: Ref<HTMLDivElement | HTMLLIElement> — The row's element: the `div`, or the `li` with `as="li"`.
- label: ReactNode — The control's name, shown over or before it; a click on it reaches the control.
- description?: ReactNode — A grey line under the label, read out with the control; none by default.
- separator?: boolean — The hairline under the row: `true` draws it always, `false` never; left out, it is drawn under every row but not under the last of its siblings.
- disabled?: boolean — Dims the words to half and disables the control the field wires (a link takes no `disabled`); off by default.
- media?: ReactNode — What the row shows before its words — the theme's `IconTile` marking the row's subject.
- stack?: boolean | 'always' — Whether the row stacks its words above its control: `"always"` at every width (a MultiSelect, a Textarea or a long Select in a settings list); `true` at or below 640 px; `false` never.
- children: ReactElement<Partial<FieldControlProps>> | ((control: FieldControlProps) => ReactNode) — The control (a Switch, TextInput, Select, Textarea or Slider) or a function given its wiring.
- Another example of it: field-error.md, input-group.md, rating.md, textarea.md
- Types: FieldControlProps = { id: string; 'aria-describedby'?: string; disabled?: boolean }

## Keyboard

- Space: toggle
- ArrowDown / ArrowUp: move highlight
- Enter: choose highlighted
- Escape: dismiss

## Accessibility

- The part itself answers the keys above.
- hover, active, focus-visible, focus-within: the browser's own (:hover, :active, :focus-visible, :focus-within): write nothing
- checked: the prop defaultChecked
- disabled: the prop disabled

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Card](/themes/trail/components/card): A framed surface that holds one piece of content or a list of settings rows.
- [Switch](/themes/trail/components/switch): An on/off control for a setting that takes effect at once.
- [Multi select](/themes/trail/components/multi-select): A field holding several values picked from a fixed list.
- [Field error](/themes/trail/components/field-error): The error line under a form control whose value was refused, saying what to fix, inside the control's Field.
