Input Group
One field with things inside it: a prefix, a unit, a keycap hint, a copy button, a send button. The whole group wears the same surface, focus line and error state as an Input, so it sits in a form beside one. Use Input with its icon and trailing slot first; reach for a group when the extras are text, buttons or a toolbar.
Install
npx shadcn@latest add @nelumbo/input-groupPrefix and suffix
Text addons set the context of the value: a scheme, a currency, a domain. Clicking them puts the caret in the field.
Search with a keycap hint
The hint is drawn like the shortcuts in menus and hides once you type. A spinner takes its place while results load.
Buttons
InputGroupButton is a tonal pill (secondary) by default; use variant ghost for quiet icon toggles. Sizes: xs, sm, icon-xs, icon-sm.
Chat composer
Block addons put a toolbar above or below a textarea. The textarea grows with its text; the send button is a quiet pill until there is something to send, then it fills and springs into a rounded square. Cmd or Ctrl + Enter sends.
Block start
A block-start addon sits above the control: a label row, tags, or a reply-to quote.
Invalid and disabled
Put aria-invalid on the control (or data-invalid on the group) and the whole group turns red with a thicker line. Disabled on the control dims it.
Enter the part before the @ only.
Usage
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea,} from "@/components/ui/input-group"// shadcn's API, unchanged<InputGroup> <InputGroupAddon><InputGroupText>https://</InputGroupText></InputGroupAddon> <InputGroupInput aria-label="Website" placeholder="nelumbo" /> <InputGroupAddon align="inline-end"><InputGroupText>.com</InputGroupText></InputGroupAddon></InputGroup>// Nelumbo adds keycaps and tonal pill buttons<InputGroup> <InputGroupInput aria-label="Search" placeholder="Search" /> <InputGroupAddon align="inline-end"><InputGroupKeys>⌘K</InputGroupKeys></InputGroupAddon></InputGroup>Props
| Prop | Type | Default | Part |
|---|---|---|---|
InputGroup | div props | The field. Height 40px; grows when it has a block addon or a textarea | |
InputGroupAddon align | "inline-start" | "inline-end" | "block-start" | "block-end" | "inline-start" | Where the addon draws, whatever its place in the JSX. Click focuses the control |
InputGroupButton variant | Button variant | "secondary" | Tonal pill; ghost for quiet toggles |
InputGroupButton size | "xs" | "sm" | "icon-xs" | "icon-sm" | "xs" | Icon-only sizes need an aria-label |
InputGroupText | span props | Prefix or suffix text (https://, .com, USD). Icons inside take the text color | |
InputGroupKeys | span props | Keycap hint: "⌘K", "Ctrl+Enter" | |
InputGroupInput | input props | Bare input; give it an aria-label (no floating label here) | |
InputGroupTextarea | textarea props | rows 1 | Grows with its text up to 12rem, then scrolls |