Skip to content

Input group

An input or textarea with leading and trailing addons, buttons and text.

With an icon

With text

https://
.example.com
$
USD

With a button

With a keyboard shortcut

/

With a textarea

Comment on INV-2041

Disabled

Invalid

$

Installation

npx shadcn@latest add @khaeli/input-group

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

npm packages
  • class-variance-authority ^0.7.1

Keyboard

Tab
Moves from the control to each button in the group, in the order they are written.
EnterSpace
Activate a focused button.

Accessible name

  • The name belongs to the control: give InputGroupInput or InputGroupTextarea an id and point a @khaeli/label at it with htmlFor, or give it an aria-label.
  • An icon-only InputGroupButton needs an aria-label that says what it does. An icon in an addon is decoration.
  • Text in an addon, such as a currency sign or a unit, is not part of the name. If the value cannot be understood without it, say it in the label: Amount in US dollars.
  • For an invalid group, put aria-invalid and aria-describedby on the control. The whole group takes the invalid ring.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/input-group.json