Skip to content
SevenOne

Search documentation

Search pages and components

Input Group

Adds icons, text and buttons inside an input or a textarea. 44px tall with 16px text; the small buttons keep a 44px hit area.

Installation

npx shadcn@latest add @sevenone/input-group

Usage

import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
  InputGroupText,
  InputGroupTextarea,
} from "@/components/ui/input-group"

Examples

Icon and text

12 results
<InputGroup>
  <InputGroupInput placeholder="Search…" aria-label="Search" />
  <InputGroupAddon>
    <Search aria-hidden="true" />
  </InputGroupAddon>
  <InputGroupAddon align="inline-end">12 results</InputGroupAddon>
</InputGroup>

Button

The 24px button keeps an invisible 44px hit area.

<InputGroup>
  <InputGroupInput defaultValue="https://docs.sevenone.io/r/button.json" readOnly aria-label="Registry address" />
  <InputGroupAddon align="inline-end">
    <InputGroupButton size="icon-xs" aria-label="Copy">
      <Copy />
    </InputGroupButton>
  </InputGroupAddon>
</InputGroup>

Text

https://
.com
<Label htmlFor="site">Website</Label>
<InputGroup>
  <InputGroupAddon>
    <InputGroupText>https://</InputGroupText>
  </InputGroupAddon>
  <InputGroupInput id="site" placeholder="example" className="pl-1" />
  <InputGroupAddon align="inline-end">
    <InputGroupText>.com</InputGroupText>
  </InputGroupAddon>
</InputGroup>

Textarea

align="block-end" puts the actions under the text. Leave 12px between small buttons so their hit areas do not overlap.

52% used
<InputGroup>
  <InputGroupTextarea placeholder="Ask, search or chat…" aria-label="Message" />
  <InputGroupAddon align="block-end" className="gap-3">
    <InputGroupButton variant="outline" size="icon-xs" aria-label="Add a file">
      <Plus />
    </InputGroupButton>
    <InputGroupText className="ml-auto">52% used</InputGroupText>
    <Separator orientation="vertical" className="h-4!" />
    <InputGroupButton variant="default" size="icon-xs" aria-label="Send">
      <ArrowUp />
    </InputGroupButton>
  </InputGroupAddon>
</InputGroup>

Accessibility

  • Give the input a Label, or an aria-label when the design has no visible label.
  • Icons are decoration, so mark them aria-hidden; icon-only buttons need an aria-label.
  • The whole group shows the 2px focus ring when its input has keyboard focus.
  • Clicking an addon focuses the input, so the full width of the group works as a target.