---
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/"
---

# Input group

A text field with add-ons inside its frame, for a web address, a unit, a search with its key or a copy field, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `InputGroup`.

## Try it

Type a web address after its https://, a weight before its kg, a handle checked as you type (teodora is taken), copy the invite link or the study id (the button says Copied, and the line under them what was copied), apply the code FIELD20 (it says Applied), and press / to filter the studies, the cross clearing the filter.

The handle check is a list of three names behind a short wait; Apply only knows one code, behind a short wait. Copy puts the real words on your clipboard.

## When to use

- A text field with add-ons inside its frame, for a web address, a unit, a search with its key or a copy field.
- Use InputGroup for a field with something inside its frame; a plain field stays TextInput, a search bar SearchInput, a password PasswordField. A button inside is the quiet one: never a filled button inside a field.

## 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 Input group on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-input-group.json --yes
```

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

## Usage

```tsx
import { InputGroup, InputGroupInput, InputGroupAddon, InputGroupIcon, InputGroupText, InputGroupButton, InputGroupIconButton, InputGroupClear } from '@/components/ui/goop/input-group';
import { Field } from '@/components/ui/goop/field';

<>
  <Field label="Website" orientation="vertical">
    <InputGroup>
      <InputGroupAddon>
        <InputGroupText>https://</InputGroupText>
      </InputGroupAddon>
      <InputGroupInput type="url" defaultValue="fieldwork.example" />
      <InputGroupAddon side="end">
        <InputGroupIconButton copy icon="copy" aria-label="Copy address" />
      </InputGroupAddon>
    </InputGroup>
  </Field>
  <Field label="Discount code" orientation="vertical">
    <InputGroup>
      <InputGroupInput placeholder="Code" />
      <InputGroupAddon side="end">
        <InputGroupButton
          doneLabel="Applied"
          onClick={async () => {
            const answer = await fetch('/api/discount', { method: 'POST' });
            return answer.ok;
          }}
        >
          Apply
        </InputGroupButton>
      </InputGroupAddon>
    </InputGroup>
  </Field>
  <InputGroup size="sm">
    <InputGroupAddon>
      <InputGroupIcon icon="search" />
    </InputGroupAddon>
    <InputGroupInput type="search" aria-label="Search notes" placeholder="Search notes" />
    <InputGroupAddon side="end">
      <InputGroupClear aria-label="Clear search" />
    </InputGroupAddon>
  </InputGroup>
</>
```

- Fits: settings (its recipe).
- Also known as: InputAddon, InputAdornment, InputAffix, TextFieldSlot, InputWithIcon.
- height, width, padding, gap, corner, border, background, text, motion: add no class for these.

## API reference

### Options

- `size: sm | md | lg = md`
- `id?: string` — The field's id, handed to the InputGroupInput (a Field's label points at it).
- `aria-describedby?: string` — What describes the field, handed to the InputGroupInput (a Field's description, a FieldInvalid's error).
- `aria-invalid?: ComponentProps<'input'>['aria-invalid']` — Marks the field invalid (a FieldInvalid hands it): the frame's edge turns the danger colour.
- `disabled?: boolean` — Disables the field and every button in the group; the frame dims.

### Parts

- `InputGroupInput` — The field inside an InputGroup; type?: 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' — The input's own `type`; left out, `text`; also takes value?: string; defaultValue?: string; onChange?: (event: ChangeEvent<HTMLInputElement>) => void; name?: string; required?: boolean; disabled?: boolean; form?: string
- `InputGroupAddon` — A holder of add-ons inside the frame; side: start (default), end
- `InputGroupIcon` — A pack icon in an add-on; icon: IconName — The pack icon's own name
- `InputGroupText` — A short text in an add-on — "https
- `InputGroupButton` — A quiet button of words in an add-on ("Apply", "Copy"); its props: input-group--button.md
- `InputGroupIconButton` — A quiet icon button in an add-on (copy, show, open); its props: input-group--icon-button.md
- `InputGroupClear` — The clear button in an add-on; its props: input-group--clear.md

### InputGroupButton

A quiet button of words in an add-on ("Apply", "Copy").

```tsx
import { InputGroupButton } from '@/components/ui/goop/input-group';
```

### Options

- copy?: boolean | string — Copies on a press: `true` the field's value, a text that text.
- doneLabel?: string
- failedLabel?: string — The words when a copy failed (default "Couldn’t copy").
- onCopy?: (value: string) => void — Called with the copied text once it is on the clipboard.
- onClick?: (event: MouseEvent<HTMLButtonElement>) => unknown — The press: with `doneLabel`, a promise it returns that resolves shows `doneLabel`; one resolving to `false`, rejecting or calling `event.preventDefault()` shows nothing (say what went wrong in the field's error line).
- Also takes: type?: 'button' | 'submit' | 'reset'; disabled?: boolean; loading?: boolean = false; loadingLabel?: string = 'Loading'

### InputGroupClear

The clear button in an add-on.

```tsx
import { InputGroupClear } from '@/components/ui/goop/input-group';
```

### Options

- onClick?: (event: MouseEvent<HTMLButtonElement>) => unknown — The press: with `doneLabel`, a promise it returns that resolves shows `doneLabel`; one resolving to `false`, rejecting or calling `event.preventDefault()` shows nothing (say what went wrong in the field's error line).
- aria-label?: string — The button's name, read by a screen reader and shown in its tooltip (default "Clear").
- children?: ReactNode
- Also takes: type?: 'button' | 'submit' | 'reset'; disabled?: boolean; tooltip?: string | false; tooltipKeys?: readonly string[]; loading?: boolean = false; loadingLabel?: string = 'Loading'

### InputGroupIconButton

A quiet icon button in an add-on (copy, show, open).

```tsx
import { InputGroupIconButton } from '@/components/ui/goop/input-group';
```

### Options

- copy?: boolean | string — Copies on a press: `true` the field's value, a text that text.
- doneLabel?: string
- failedLabel?: string — The words when a copy failed (default "Couldn’t copy").
- onCopy?: (value: string) => void — Called with the copied text once it is on the clipboard.
- onClick?: (event: MouseEvent<HTMLButtonElement>) => unknown — The press: with `doneLabel`, a promise it returns that resolves shows `doneLabel`; one resolving to `false`, rejecting or calling `event.preventDefault()` shows nothing (say what went wrong in the field's error line).
- icon: IconName — The pack icon's own name.
- Also takes: type?: 'button' | 'submit' | 'reset'; disabled?: boolean; aria-label: string; tooltip?: string | false; tooltipKeys?: readonly string[]; loading?: boolean = false; loadingLabel?: string = 'Loading'

## Keyboard

- Tab: move from the field to each button inside its frame, in order, then on to the next control
- Enter / Space: on a button inside the frame: press it (the clear button empties the field and puts the focus back in it)
- Escape: in a search field holding words: empty it; an empty one lets Escape through

## Accessibility

- The native element answers the keyboard.
- hover, active, focus: the browser's own (:hover, :active, :focus): write nothing
- disabled: the prop disabled
- invalid: the attribute data-invalid

## Motion

- The part sets its own motion: add no transition or animation of your own.

## 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.

Shortened to fit: the data-slot values.

## Related

- [Field](/themes/trail/components/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.
- [OTP input](/themes/trail/components/otp-input): A row of single-character cells for a one-time code, for a two-step sign-in or confirming an email or a phone.
- [Checkbox](/themes/trail/components/checkbox): A box a person ticks to turn one option on or off.
- [Radio group](/themes/trail/components/radio-group): A named group of options of which exactly one is chosen.
