Input Group
The React Input Group component lets you combine an input field with icons, text, or buttons on a single line. It helps you add extra context or actions directly inside the input.
It is useful for things like search bars, URLs, or password fields. For example, you can add a search icon, a submit button, or a suffix like “@tailgrids.com” next to the input.
Built with React and styled using Tailwind CSS. It supports flexible layouts with add-ons, buttons, and text areas.
Installation
Install the component using the Tailgrids CLI.
npx @tailgrids/cli add input-groupAnatomy
Import the components and build your input group structure:
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
InputGroupButton,
InputGroupTextarea
} from "@/registry/core/input-group";
import { Search1 } from "@tailgrids/icons";
export const InputGroupExample = () => (
<InputGroup>
<InputGroupAddon align="inline-start">
<Search1 className="h-4 w-4" />
</InputGroupAddon>
<InputGroupInput placeholder="Search..." />
<InputGroupAddon align="inline-end">
<InputGroupButton size="xs">Submit</InputGroupButton>
</InputGroupAddon>
</InputGroup>
);Examples
Addons
Combine inputs with text or icon addons to give users more context (e.g., an email domain or a currency symbol).
Buttons
You can attach multiple interactive buttons inline. Helpful for actions like copying a link, showing/hiding a password, or clearing an input.
Alignment
Display helper text or specific context headers/footers above or below your input field using block-start or block-end alignment.
Textarea
You can use the InputGroupTextarea component to build multi-line input groups.
API Reference
InputGroup
The root container that wraps all input group elements. Renders as a <div>.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes for the container |
InputGroupInput
An inline input control rendered inside the group. Accepts all props from the base Input component.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes for the input |
InputGroupTextarea
A multi-line textarea control rendered inside the group. Accepts all props from the base TextArea component.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes for the textarea |
InputGroupAddon
A non-interactive addon element (icon, text, label) attached to the input group.
| Prop | Type | Default | Description |
|---|---|---|---|
align | "inline-start" | "inline-end" | "block-start" | "block-end" | "inline-start" | Position of the addon relative to the input |
className | string | - | Additional CSS classes for the addon container |
InputGroupButton
An interactive button rendered inside the input group. Renders as a <button type="button">.
| Prop | Type | Default | Description |
|---|---|---|---|
size | "xs" | "icon-xs" | "sm" | "icon-sm" | "xs" | Controls the button's size and padding |
className | string | - | Additional CSS classes for the button |
Accessibility
- Label association: Input groups are visual wrappers, so labels should be linked to the input using
htmlForandid, or provided through a field wrapper. - Keyboard support: Inputs and buttons inside the group follow native keyboard behavior. Users can type, move between elements using
Tab, and activate buttons usingEnterorSpace. - Focus behavior: Each interactive element (input, textarea, button) receives focus independently, with visible focus states for better usability.
- Icon buttons: Buttons that contain only icons should include an
aria-label(for example, “Search” or “Show password”) so their purpose is clear to screen readers. - Grouped context: Prefixes, suffixes, and addons provide visual context, but additional labels or helper text may be needed to clearly describe the input purpose.
