InputGroup
a composable input group with addons, buttons, and text
Installation
pnpm dlx shadcn@latest add https://prototyper-ui.com/r/input-group.jsonnpx shadcn@latest add https://prototyper-ui.com/r/input-group.jsonyarn dlx shadcn@latest add https://prototyper-ui.com/r/input-group.jsonbunx --bun shadcn@latest add https://prototyper-ui.com/r/input-group.jsonThis will add the following files to your project:
components/ui/input-group.tsx
Note: This component depends on Button, Input, and Textarea. They will be installed automatically.
Usage
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
} from "@/components/ui/input-group"
<InputGroup>
<InputGroupInput placeholder="Search..." />
<InputGroupAddon align="inline-end">
<InputGroupButton>Go</InputGroupButton>
</InputGroupAddon>
</InputGroup>Anatomy
<InputGroup>
<InputGroupAddon>
<InputGroupText />
<InputGroupButton />
</InputGroupAddon>
<InputGroupInput />
</InputGroup>Or with a textarea:
<InputGroup>
<InputGroupAddon>
<InputGroupText />
</InputGroupAddon>
<InputGroupTextarea />
</InputGroup>| Sub-component | data-slot | Purpose | Required |
|---|---|---|---|
InputGroup | input-group | Root wrapper, provides group styling context | Yes |
InputGroupAddon | input-group-addon | Container for icons, text, buttons, or kbd hints | No |
InputGroupButton | - | A compact button styled for use inside the group | No |
InputGroupText | - | Inline text or icon container | No |
InputGroupInput | input-group-control | Single-line text input (borderless) | Yes* |
InputGroupTextarea | input-group-control | Multi-line textarea (borderless) | Yes* |
* Use either InputGroupInput or InputGroupTextarea, not both.
Styling
Data Slots
Use data-slot attributes to target specific parts of the input group:
| Slot name | Element |
|---|---|
input-group | Root wrapper <div> |
input-group-addon | Addon container (icons, buttons) |
input-group-control | The input or textarea element |
Customization Examples
/* Remove border from all input groups */
[data-slot="input-group"] {
@apply border-0 shadow-none;
}
/* Style addons */
[data-slot="input-group-addon"] {
@apply text-foreground;
}{/* Override styles via className */}
<InputGroup className="rounded-full">
<InputGroupInput placeholder="Pill input group" />
</InputGroup>API Reference
InputGroup
Root wrapper that provides grouped styling and focus management.
Prop
Type
All native div props are forwarded via ...props.
InputGroupAddon
Container for icons, text, buttons, or keyboard shortcut hints.
Prop
Type
All native div props are forwarded via ...props.
InputGroupButton
A compact button styled for use inside the input group. Extends Button props.
Prop
Type
All Button props (except size and type) are forwarded via ...props.
InputGroupText
Inline text or icon container for display content inside the group.
Prop
Type
All native span props are forwarded via ...props.
InputGroupInput
A borderless single-line input styled for use inside the group. Built on Input.
Prop
Type
All native input props are forwarded via ...props.
InputGroupTextarea
A borderless multi-line textarea styled for use inside the group. Built on Textarea.
Prop
Type
All native textarea props are forwarded via ...props.
Accessibility
Keyboard Interactions
| Key | Action |
|---|---|
Tab | Moves focus into or out of the input/textarea |
ARIA Attributes
InputGrouprenders withrole="group"to associate the input with its addons.InputGroupAddonrenders withrole="group"for semantic grouping.- Clicking an addon area focuses the input for better usability.
- Pair with a
<label>oraria-labelon the input to ensure accessibility.