View fulldotdev/ui on GitHub

Input Group

Add addons, buttons, and helper content to inputs.

Installation

npx shadcn@latest add @fulldev/input-group

Usage

import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
  InputGroupText,
  InputGroupTextarea,
} from "@/components/ui/input-group"
<InputGroup>
  <InputGroupInput placeholder="Search..." />
  <InputGroupAddon>
    <SearchIcon />
  </InputGroupAddon>
</InputGroup>

Composition

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

Align

Place InputGroupAddon after InputGroupInput or InputGroupTextarea in the DOM for correct focus order, then use its align prop to position it visually. Clicking an addon outside a button or link focuses the control.

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.

Icon

Text

Button

To open a popover or dropdown menu from an InputGroupButton, put the root inside the addon and give the button the trigger slot, such as data-slot="popover-trigger".

Kbd

Spinner

Textarea

Custom Input

Add data-slot="input-group-control" to a custom control for the focus state and addon click handling. This one grows with its content through field-sizing-content.

RTL

API Reference

Source: src/components/ui/input-group

InputGroupAddon

PropTypeDefault
align"inline-start" | "inline-end" | "block-start" | "block-end""inline-start"

Use inline-start or inline-end with InputGroupInput, and block-start or block-end with InputGroupTextarea. An addon can hold several buttons, icons and texts.

InputGroupButton

PropTypeDefault
size"xs" | "icon-xs" | "sm" | "icon-sm""xs"
variant"default" | "destructive" | "outline" | "secondary" | "ghost" | "link""ghost"
type"button" | "submit" | "reset""button"

With href, it renders a link.

InputGroupInput and InputGroupTextarea

Replacements for Input and Textarea inside an input group. They pass all other attributes to the underlying control and set data-slot="input-group-control".