npx shadcn@4.23.1 add @goop/meadow-input-groupInput group
FreeA text field with an action joined to it inside its fill, for React and Tailwind CSS. Free, MIT.
What an agent sees
- InputGroupInputThe field inside the group
- InputGroupAddonA 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 - InputGroupIconA pack icon in a holder
- InputGroupTextA short text in a holder — "https
- InputGroupButtonA button of words in an end holder ("Apply", "Copy")
- InputGroupIconButtonThe action joined to the field
- InputGroupClearThe clear button at the field's end, in an
InputGroupAddon side="end"
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>
);
}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.
npx shadcn@4.23.1 add @goop/meadow-input-groupAdd the Goop Input group to this project. The install steps are at https://goop.so/docs/install.mdUsage
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
| Option | Type | What it does |
|---|---|---|
| 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
| Part | What it is |
|---|---|
| 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
InputGroupClear
The clear button at the field's end, in an InputGroupAddon side="end".
import { InputGroupClear } from '@/components/ui/goop/input-group';Options
- onClick?: (event: MouseEvent<HTMLButtonElement>) => unknown — The press, and with
doneLabelits work: a promise it returns that resolves showsdoneLabel, while one that resolves tofalseor rejects shows nothing, nor does a press whose handler callsevent.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;
Clearby default. - onClear?: () => void — Called after the field is emptied (its
onChangehas 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'
Accessibility
- The native element answers the keyboard.
- hover, active: the browser's own (:hover, :active): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| 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.