Input Group
A text field with icons, text or buttons inside it.
@cupertinoui/input-groupRegistry JSON import { ArrowUpIcon, AtSignIcon, LockIcon, SearchIcon } from "lucide-react"
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea } from "@/components/ui/input-group"
import { Kbd } from "@/components/ui/kbd"
export default function InputGroupDemo() {
return (
<div className="flex w-full max-w-sm flex-col gap-4">
<InputGroup>
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
<InputGroupInput placeholder="Search" />
<InputGroupAddon align="inline-end">
<Kbd>⌘F</Kbd>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupAddon>
<InputGroupText>
<LockIcon /> https://
</InputGroupText>
</InputGroupAddon>
<InputGroupInput defaultValue="appleseed.example" />
</InputGroup>
<InputGroup>
<InputGroupInput placeholder="Username" />
<InputGroupAddon align="inline-end">
<InputGroupText>
<AtSignIcon /> icloud.com
</InputGroupText>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupTextarea placeholder="iMessage" rows={2} />
<InputGroupAddon align="block-end" className="justify-end">
<InputGroupButton variant="default" size="icon-xs" className="rounded-full" aria-label="Send">
<ArrowUpIcon strokeWidth={2.5} />
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</div>
)
}Installation
pnpm dlx shadcn@latest add @cupertinoui/input-groupThe first install also adds the macOS theme. See Installation to set up the registry.
Usage
import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/ui/input-group"
<InputGroup>
<InputGroupAddon><SearchIcon /></InputGroupAddon>
<InputGroupInput placeholder="Search" />
</InputGroup>API Reference
Every part forwards the props of the underlying element. The props below are the ones CupertinoUI adds or changes.
InputGroupAddon
| Prop | Type | Description |
|---|---|---|
align | "inline-start" | "inline-end" | "block-start" | "block-end"Default: "inline-start" | Where the addon sits. |
className | string | Extra classes, merged with the component's own. |
InputGroupButton
| Prop | Type | Description |
|---|---|---|
size | "xs" | "sm" | "icon-xs" | "icon-sm"Default: "xs" | A small button that fits inside the field. |
className | string | Extra classes, merged with the component's own. |
InputGroupInput / InputGroupTextarea / InputGroupText
| Prop | Type | Description |
|---|---|---|
className | string | Extra classes, merged with the component's own. |