---
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 an action joined to it inside its fill, for React and Tailwind CSS. Free, MIT.

Free. 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 an action joined to it inside its fill.

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

```sh
npx shadcn@4.23.1 add @goop/meadow-input-group
```

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

## Usage

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

import { useState } from 'react';
import {
  InputGroup,
  InputGroupAddon,
  InputGroupClear,
  InputGroupIconButton,
  InputGroupInput,
} from '@/components/ui/goop/input-group';

function SiteLabelField({ onPickMarker }: { onPickMarker: () => void }) {
  const [label, setLabel] = useState('Mill');
  return (
    <InputGroup>
      <InputGroupAddon side="start">
        <InputGroupIconButton icon="tag" aria-label="Choose a site marker" onClick={onPickMarker} />
      </InputGroupAddon>
      <InputGroupInput
        aria-label="Site label"
        placeholder="Site label"
        value={label}
        onChange={(event) => setLabel(event.target.value)}
      />
      <InputGroupAddon side="end">
        <InputGroupClear aria-label="Clear the site label" />
      </InputGroupAddon>
    </InputGroup>
  );
}
```

- Also known as: InputAddon, InputAdornment, InputAffix, TextFieldSlot, InputWithIcon.
- height, width, padding, gap, corner, background, text, motion: add no class for these.

## API reference

### Options

- `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).
- `aria-invalid?: ComponentProps<'input'>['aria-invalid']` — Marks the field invalid: its inside edge turns the danger colour.
- `disabled?: boolean` — Disables the field and every button in the group; they fade to half.
- `size?: 'sm' | 'md' | 'lg' = 'md'` — The field's height: `sm` 36 px, `md` 44 px (the default) or `lg`, the same 44 px.

- Types: InputGroupInputType = TextInputType

### Parts

- `InputGroupInput` — The field inside the group; type?: InputGroupInputType — 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 for one action at the start or the end of the field (`side`), laid over the field's fill and as tall as it; the field's words make room for it; side: start (default), end
- `InputGroupIcon` — A pack icon in a holder; icon: IconName — The pack icon's own name
- `InputGroupText` — A short text in a holder — "https
- `InputGroupButton` — A button of words in an end holder ("Apply", "Copy"); its props: input-group--button.md
- `InputGroupIconButton` — The action joined to the field; its props: input-group--icon-button.md
- `InputGroupClear` — The clear button at the field's end, in an `InputGroupAddon side="end"`; its props: input-group--clear.md

- Class recipes (cva): inputGroupAddonVariants (InputGroupAddon)
- data-slot values (to select a part by): input-group, input-group-addon, input-group-button, input-group-button-status, input-group-clear, input-group-icon, input-group-icon-button, input-group-icon-button-status, input-group-input, input-group-text

### InputGroupButton

A button of words in an end holder ("Apply", "Copy").

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

### Options

- copy?: boolean | string — Copies on a press: `true` copies the field's value as it is at the press, a text copies that text.
- doneLabel?: string — The words once the press has done its work, shown with the check for 2 s: "Copied" by default on a `copy` button; on another button your own word ("Applied"), shown once its `onClick`'s promise resolves (at once when it returns no promise).
- failedLabel?: string — The words when a copy found no clipboard or the browser refused it (default "Couldn’t copy").
- onCopy?: (value: string) => void — Called with the copied text once it is on the clipboard (never when the copy failed).
- onClick?: (event: MouseEvent<HTMLButtonElement>) => unknown — The press, and with `doneLabel` its work: a promise it returns that resolves shows `doneLabel`, while one that resolves to `false` or rejects shows nothing, nor does a press whose handler calls `event.preventDefault()`.
- Also takes: type?: 'button' | 'submit' | 'reset'; disabled?: boolean; loading?: boolean = false; loadingLabel?: string = 'Loading'

### InputGroupClear

The clear button at the field's end, in an `InputGroupAddon side="end"`.

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

### Options

- onClick?: (event: MouseEvent<HTMLButtonElement>) => unknown — The press, and with `doneLabel` its work: a promise it returns that resolves shows `doneLabel`, while one that resolves to `false` or rejects shows nothing, nor does a press whose handler calls `event.preventDefault()`.
- children?: ReactNode — With `asChild`: the one element (a link) that becomes the button, the icon drawn in it.
- aria-label?: string = 'Clear' — The button's name, read by a screen reader and shown in its tooltip; `Clear` by default.
- onClear?: () => void — Called after the field is emptied (its `onChange` has had the empty value already).
- Also takes: type?: 'button' | 'submit' | 'reset'; disabled?: boolean; tooltip?: string | false; tooltipKeys?: readonly string[]; loading?: boolean = false; loadingLabel?: string = 'Loading'

### InputGroupIconButton

The action joined to the field.

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

### Options

- copy?: boolean | string — Copies on a press: `true` copies the field's value as it is at the press, a text copies that text.
- doneLabel?: string — The words once the press has done its work, shown with the check for 2 s: "Copied" by default on a `copy` button; on another button your own word ("Applied"), shown once its `onClick`'s promise resolves (at once when it returns no promise).
- failedLabel?: string — The words when a copy found no clipboard or the browser refused it (default "Couldn’t copy").
- onCopy?: (value: string) => void — Called with the copied text once it is on the clipboard (never when the copy failed).
- onClick?: (event: MouseEvent<HTMLButtonElement>) => unknown — The press, and with `doneLabel` its work: a promise it returns that resolves shows `doneLabel`, while one that resolves to `false` or rejects shows nothing, nor does a press whose handler calls `event.preventDefault()`.
- icon: IconName — The pack icon's own name.
- aria-label: string — The button's name: an icon-only button has no words to be named by.
- children?: ReactNode — With `asChild`: the one element (a link) that becomes the button, the icon drawn in it.
- Also takes: asChild?: boolean; type?: 'button' | 'submit' | 'reset'; disabled?: boolean; tooltip?: string | false; tooltipKeys?: readonly string[]; loading?: boolean = false; loadingLabel?: string = 'Loading'

## Accessibility

- The native element answers the keyboard.
- hover, active: the browser's own (:hover, :active): write nothing
- focus-visible: the attribute data-focus-visible
- pressed: the attribute aria-pressed
- expanded: the attribute data-state=open
- open: the attribute data-state=open
- disabled: the prop disabled
- invalid: the attribute aria-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.

## Related

- [OTP input](/themes/meadow/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/meadow/components/checkbox): A round box a person ticks to mark one thing done or chosen.
- [Radio group](/themes/meadow/components/radio-group): A named group of options of which exactly one is chosen, each option a whole row a press anywhere on chooses.
- [Choice group](/themes/meadow/components/choice-group): A group of choices for a form, a row each, with its label, a description and one error for the whole group.
