Skip to content
GitHub

Input Group

Add addons, buttons, and helper content to inputs.

12 results
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
} from "@/components/ui/pxl/input-group";
export default function InputGroupDemo() {
return (
<InputGroup className="max-w-xs">
<InputGroupInput placeholder="Search..." />
<InputGroupAddon>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 24 24"
>
<path d="M22 22h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-6-2H6v-2h8v2Zm4 0h-2v-2h2v2ZM6 16H4v-2h2v2Zm10 0h-2v-2h2v2ZM4 14H2V6h2v8Zm14 0h-2V6h2v8ZM6 6H4V4h2v2Zm10 0h-2V4h2v2Zm-2-2H6V2h8v2Z" />
</svg>
</InputGroupAddon>
<InputGroupAddon align="inline-end">12 results</InputGroupAddon>
</InputGroup>
);
}
pnpm dlx shadcn@latest add pxl-ui/registry/input-group
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
InputGroupText,
InputGroupTextarea,
} from "@/components/ui/pxl/input-group"
<InputGroup>
<InputGroupInput placeholder="Search..." />
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
</InputGroup>

Use the following composition to build an InputGroup:

InputGroup
├── InputGroupInput or InputGroupTextarea
├── InputGroupAddon
├── InputGroupButton
└── InputGroupText

Use the align prop on InputGroupAddon to position the addon relative to the input.

Use align="inline-start" to position the addon at the start of the input. This is the default.

Use align="inline-end" to position the addon at the end of the input.

Use align="block-start" to position the addon above the input.

Use align="block-end" to position the addon below the input.

Add the data-slot="input-group-control" attribute to your custom input for automatic focus state handling.

The main component that wraps inputs and addons.

Prop Type Default
className string
<InputGroup>
<InputGroupInput />
<InputGroupAddon />
</InputGroup>

Displays icons, text, buttons, or other content alongside inputs.

Prop Type Default
align "inline-start" | "inline-end" | "block-start" | "block-end" "inline-start"
className string
<InputGroupAddon align="inline-end">
<SearchIcon />
</InputGroupAddon>

For <InputGroupInput />, use the inline-start or inline-end alignment. For <InputGroupTextarea />, use the block-start or block-end alignment.

The InputGroupAddon component can have multiple InputGroupButton components and icons.

<InputGroupAddon>
<InputGroupButton>Button</InputGroupButton>
<InputGroupButton>Button</InputGroupButton>
</InputGroupAddon>

Displays buttons within input groups.

Prop Type Default
size "xs" | "icon-xs" | "sm" | "icon-sm" "xs"
variant "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" "ghost"
className string
<InputGroupButton>Button</InputGroupButton>
<InputGroupButton size="icon-xs" aria-label="Copy">
<CopyIcon />
</InputGroupButton>

Replacement for <Input /> when building input groups. This component has the input group styles pre-applied and uses the unified data-slot="input-group-control" for focus state handling.

Prop Type Default
className string

All other props are passed through to the underlying <Input /> component.

<InputGroup>
<InputGroupInput placeholder="Enter text..." />
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
</InputGroup>

Replacement for <Textarea /> when building input groups. This component has the textarea group styles pre-applied and uses the unified data-slot="input-group-control" for focus state handling.

Prop Type Default
className string

All other props are passed through to the underlying <Textarea /> component.

<InputGroup>
<InputGroupTextarea placeholder="Enter message..." />
<InputGroupAddon align="block-end">
<InputGroupButton>Send</InputGroupButton>
</InputGroupAddon>
</InputGroup>