--- title: Input Group description: Add addons, buttons, and helper content to inputs. base: base component: true --- import { IconInfoCircle } from "@tabler/icons-react" ## Installation Command Manual ```bash npx shadcn@latest add input-group ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx showLineNumbers import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, } from "@/components/ui/input-group" ``` ```tsx showLineNumbers ``` ## Align Use the `align` prop on `InputGroupAddon` to position the addon relative to the input. For proper focus management, `InputGroupAddon` should always be placed after `InputGroupInput` or `InputGroupTextarea` in the DOM. Use the `align` prop to visually position the addon. ### inline-start Use `align="inline-start"` to position the addon at the start of the input. This is the default. ### inline-end Use `align="inline-end"` to position the addon at the end of the input. ### block-start Use `align="block-start"` to position the addon above the input. ### block-end Use `align="block-end"` to position the addon below the input. ## Examples ### Icon ### Text ### Button ### Kbd ### Dropdown ### Spinner ### Textarea ### Custom Input 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. ## RTL To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl). ## API Reference ### InputGroup The main component that wraps inputs and addons. | Prop | Type | Default | | ----------- | -------- | ------- | | `className` | `string` | | ```tsx ``` ### InputGroupAddon Displays icons, text, buttons, or other content alongside inputs. } title="Focus Navigation"> For proper focus navigation, the `InputGroupAddon` component should be placed after the input. Set the `align` prop to position the addon. | Prop | Type | Default | | ----------- | ---------------------------------------------------------------- | ---------------- | | `align` | `"inline-start" \| "inline-end" \| "block-start" \| "block-end"` | `"inline-start"` | | `className` | `string` | | ```tsx ``` **For ``, use the `inline-start` or `inline-end` alignment. For ``, use the `block-start` or `block-end` alignment.** The `InputGroupAddon` component can have multiple `InputGroupButton` components and icons. ```tsx Button Button ``` ### InputGroupButton 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` | | ```tsx Button ``` ### InputGroupInput Replacement for `` 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 `` component. ```tsx ``` ### InputGroupTextarea Replacement for `