Component guideEditable source

Input Group

A field with attached labels, units, icons, or action controls.

Original component docs
On this page4 sectionsBack to top

Use Input Group to keep a field and its supporting controls together. The root is a layout container, not an input or form. Use InputGroupInput or InputGroupTextarea for the actual value.

The component module owns its client boundary, so a Next.js App Router page can import these parts while remaining a Server Component. Put your own state and event callbacks in a Client Component. Clicking a non-button addon focuses its input or textarea. An addon onClick runs before that focus action and can cancel it with event.preventDefault(). InputGroupButton.className also accepts a function of the native button state.

Live preview
Loading preview...

#Installation

Complete the base setup. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/input-group.json

#Usage

import { Search } from "lucide-react";
import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/ui/input-group";

export default function SearchField() {
  return (
    <div className="grid max-w-sm gap-2">
      <label htmlFor="site-search">Search documentation</label>
      <InputGroup>
        <InputGroupAddon>
          <Search aria-hidden="true" />
        </InputGroupAddon>
        <InputGroupInput id="site-search" name="q" type="search" placeholder="Component name" />
      </InputGroup>
    </div>
  );
}

#API reference

Prop / partPurposeDefault
InputGroupBorder and shared state stylingLayout container
InputGroupAddon.aligninline-start, inline-end, block-start, block-endinline-start
InputGroupInput / InputGroupTextareaNative field propsUncontrolled
InputGroupButton.variant / sizeAppearance; sizes xs, sm, icon-xs, icon-smghost / xs
InputGroupButton.typeNative button type: button, submit, or resetbutton
InputGroupTextNon-interactive prefix, suffix, or unitText

#Accessibility

Label the actual field, not just the group. Hide decorative icons. Name icon-only actions and explicitly set submit type when a button submits the form. Units needed to interpret a value should also appear in the label or description. Do not place a second unrelated field inside one labelled group.