# Input Group

A composable input wrapper with inline addons, buttons, and text groups.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

<DocsBaseSwitcher base="web" component="input-group" />

<ComponentPreview name="input-group" title="input-group.tsx">
<InputGroupDemo />
</ComponentPreview>

Input Group wraps a single input or textarea and lets you compose inline addons — icons, text prefixes, and buttons — in a single bordered surface.

## Installation [#installation]

<CodeTabs>
<TabsList>
<TabsTrigger value="cli">
Command
</TabsTrigger>

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

<TabsContent value="cli">
```bash
npx frakment add input-group
```

The CLI also installs the registry dependencies: `button`, `input`, and `textarea`.
</TabsContent>

<TabsContent value="manual">
<Steps>
<Step>
Install the following dependencies:
</Step>

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

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

<ComponentSource name="input-group" title="components/ui/input-group.tsx" />

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

## Usage [#usage]

```tsx title="input-group.tsx"
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
  InputGroupText,
  InputGroupTextarea,
} from "@/components/ui/input-group";
```

```tsx title="input-group.tsx"
<InputGroup>
  <InputGroupAddon>
    <Search />
  </InputGroupAddon>
  <InputGroupInput placeholder="Search..." />
</InputGroup>
```

## Composition [#composition]

```text
InputGroup
├── InputGroupInput
├── InputGroupTextarea
├── InputGroupAddon
├── InputGroupButton
└── InputGroupText
```

## Examples [#examples]

### Block end [#block-end]

`align="block-end"` stacks content below the control and lets the group grow taller automatically.

<ComponentPreview name="input-group-block-end" src="examples/input-group-block-end.tsx" title="input-group-block-end.tsx" previewClassName="h-auto py-8">
<InputGroupBlockEnd />
</ComponentPreview>

```tsx
<InputGroup>
  <InputGroupTextarea placeholder="Type a message" rows={2} />
  <InputGroupAddon align="block-end" className="justify-end">
    <InputGroupButton size="icon-sm" variant="default">
      <ArrowUpIcon />
    </InputGroupButton>
  </InputGroupAddon>
</InputGroup>
```

### Block start [#block-start]

`align="block-start"` stacks content above the control — useful for a compact inline label.

<ComponentPreview name="input-group-block-start" src="examples/input-group-block-start.tsx" title="input-group-block-start.tsx" previewClassName="h-auto py-8">
<InputGroupBlockStart />
</ComponentPreview>

```tsx
<InputGroup>
  <InputGroupAddon align="block-start">
    <InputGroupText>Subject</InputGroupText>
  </InputGroupAddon>
  <InputGroupInput placeholder="Enter a subject" />
</InputGroup>
```

### Textarea [#textarea]

Swap `InputGroupInput` for `InputGroupTextarea` to keep the same shell around a multi-line control.

<ComponentPreview name="input-group-textarea" src="examples/input-group-textarea.tsx" title="input-group-textarea.tsx" previewClassName="h-auto py-8">
<InputGroupTextareaDemo />
</ComponentPreview>

```tsx
<InputGroup>
  <InputGroupAddon align="block-start">
    <InputGroupText>Message</InputGroupText>
  </InputGroupAddon>
  <InputGroupTextarea placeholder="Write a reply..." rows={3} />
</InputGroup>
```

### Keyboard hint [#keyboard-hint]

Any element inside `InputGroupAddon` works — here a `kbd` shortcut hint on the trailing edge.

<ComponentPreview name="input-group-kbd" src="examples/input-group-kbd.tsx" title="input-group-kbd.tsx">
<InputGroupKbd />
</ComponentPreview>

```tsx
<InputGroup>
  <InputGroupAddon>
    <Search />
  </InputGroupAddon>
  <InputGroupInput placeholder="Search..." />
  <InputGroupAddon align="inline-end">
    <kbd>Ctrl K</kbd>
  </InputGroupAddon>
</InputGroup>
```

### Disabled [#disabled]

Set `data-disabled="true"` on the group, or `disabled` on the control, to fade the inline text and make the controls non-interactive.

<ComponentPreview name="input-group-disabled" src="examples/input-group-disabled.tsx" title="input-group-disabled.tsx">
<InputGroupDisabled />
</ComponentPreview>

```tsx
<InputGroup data-disabled="true">
  <InputGroupAddon>
    <Search />
  </InputGroupAddon>
  <InputGroupInput placeholder="Disabled" disabled />
</InputGroup>
```

### Invalid [#invalid]

Set `aria-invalid` on the control to trigger the destructive border and ring on the group.

<ComponentPreview name="input-group-invalid" src="examples/input-group-invalid.tsx" title="input-group-invalid.tsx">
<InputGroupInvalid />
</ComponentPreview>

```tsx
<InputGroup>
  <InputGroupAddon>
    <Search />
  </InputGroupAddon>
  <InputGroupInput
    placeholder="Invalid"
    aria-invalid
    defaultValue="Not found"
  />
</InputGroup>
```

## In Context [#in-context]

### Search with icon [#search-with-icon]

<ComponentPreview name="input-group-search" src="examples/input-group-search.tsx" title="input-group-search.tsx">
<r />
</ComponentPreview>

## API Reference [#api-reference]

### InputGroup [#inputgroup]

Extends `React.ComponentProps<"div">`. Wraps a single input or textarea with the shared border, ring, and background shell.

### InputGroupText [#inputgrouptext]

Extends `React.ComponentProps<"span">`. Static text inside an addon.

### InputGroupAddon [#inputgroupaddon]

<PropsTable rows={[{"name":"align","type":"\"inline-start\" | \"inline-end\" | \"block-start\" | \"block-end\"","defaultValue":"\"inline-start\"","description":"Position of the addon inside the group."}]} />

### InputGroupButton [#inputgroupbutton]

Extends Frakment `Button`. Accepts all button props (`variant`, `size`, `disabled`, `href`, …). Additional compact sizes:

<PropsTable rows={[{"name":"size xs","type":"\"xs\"","defaultValue":"","description":"6×24px — default for InputGroupButton."},{"name":"size icon-xs","type":"\"icon-xs\"","defaultValue":"","description":"6×6px icon-only."},{"name":"size icon-sm","type":"\"icon-sm\"","defaultValue":"","description":"8×8px icon-only."}]} />

### InputGroupInput / InputGroupTextarea [#inputgroupinput--inputgrouptextarea]

Extend native `input` / `textarea` props. Borders, ring, and background are stripped so the group provides the visual shell.

## CSS Variables [#css-variables]

| Variable | Default | Purpose |
| :-- | :-- | :-- |
| `--radius` | theme default | Corner radius of the wrapper |

## Data Attributes [#data-attributes]

| Attribute | Values |
| :-- | :-- |
| `data-slot` | `input-group`, `input-group-addon`, `input-group-button`, `input-group-text` |
| `data-align` | `inline-start` \| `inline-end` \| `block-start` \| `block-end` |
| `data-disabled` | `true` |

## Accessibility [#accessibility]

- `InputGroup` wraps a single input or textarea. Do not nest multiple controls.
- Addons are decorative; use `aria-label` on icon-only addons.
- The focus ring applies to the group, not the inner input.

## Best Practices [#best-practices]

- **One input per group.** Multiple inputs need multiple groups.
- **Addons align end or start.** Never both around the input.
- **Label the input inside.** Addons are not labels.
- **Keep addons visual.** A button inside an addon is a full Button.

## Related Components [#related-components]

- [Input](/docs/components/input) — plain input
- [Field](/docs/components/field) — label + description
- [Button Group](/docs/components/button-group) — grouped buttons