apps/v4/content/docs/components/radix/input-group.mdx
import { IconInfoCircle } from "@tabler/icons-react"
<ComponentPreview styleName="radix-nova" name="input-group-demo" previewClassName="h-[26rem]" />
npx shadcn@latest add input-group
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource name="input-group" title="components/ui/input-group.tsx" styleName="radix-nova" />
<Step>Update the import paths to match your project setup.</Step>
</Steps> </TabsContent> </CodeTabs>import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
InputGroupText,
InputGroupTextarea,
} from "@/components/ui/input-group"
<InputGroup>
<InputGroupInput placeholder="Search..." />
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
</InputGroup>
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.
<ComponentPreview styleName="radix-nova" name="input-group-inline-start" previewClassName="h-48" />
Use align="inline-end" to position the addon at the end of the input.
<ComponentPreview styleName="radix-nova" name="input-group-inline-end" previewClassName="h-48" />
Use align="block-start" to position the addon above the input.
<ComponentPreview styleName="radix-nova" name="input-group-block-start" previewClassName="h-96" />
Use align="block-end" to position the addon below the input.
<ComponentPreview styleName="radix-nova" name="input-group-block-end" previewClassName="h-[26rem]" />
<ComponentPreview styleName="radix-nova" name="input-group-icon" previewClassName="h-80" />
<ComponentPreview styleName="radix-nova" name="input-group-text" previewClassName="h-80" />
<ComponentPreview styleName="radix-nova" name="input-group-button" previewClassName="h-72" />
<ComponentPreview styleName="radix-nova" name="input-group-kbd" previewClassName="h-40" />
<ComponentPreview styleName="radix-nova" name="input-group-dropdown" previewClassName="h-56" />
<ComponentPreview styleName="radix-nova" name="input-group-spinner" previewClassName="h-80" />
<ComponentPreview styleName="radix-nova" name="input-group-textarea" previewClassName="h-96" />
Add the data-slot="input-group-control" attribute to your custom input for automatic focus state handling.
Here's an example of a custom resizable textarea from a third-party library.
<ComponentPreview styleName="radix-nova" name="input-group-custom" previewClassName="h-56" />
To enable RTL support in shadcn/ui, see the RTL configuration guide.
<ComponentPreview styleName="radix-nova" name="input-group-rtl" direction="rtl" previewClassName="h-[30rem]" />
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.
<Callout icon={<IconInfoCircle />} title="Focus Navigation">
For proper focus navigation, the InputGroupAddon component should be placed
after the input. Set the align prop to position the addon.
</Callout>
| 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>
InputGroupAdd the min-w-0 class to the InputGroup component. See diff.