videorc/ui

Input Group

One 28 px field with icons, text and buttons inside it, on the chip radius. Its focus and invalid rings draw around the whole group.

12 results

Installation

$ pnpm dlx shadcn@latest add @videorc/input-group

Usage

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

Anatomy

<InputGroup>
  <InputGroupInput /> {/* or <InputGroupTextarea /> */}
  <InputGroupAddon align="inline-start | inline-end | block-start | block-end">
    <InputGroupText />
    <InputGroupButton />
  </InputGroupAddon>
</InputGroup>

An addon's place comes from align, not from where it sits in the markup: write the input first, then its addons.

Examples

Buttons

InputGroupButton is a ghost Button at the one compact size, so it sits inside the 28 px field. Use xs for a word (Copy) and icon-xs for an icon alone (Clear search).

Textarea

With InputGroupTextarea the group grows to fit, and a block-end addon becomes the field's footer: a counter and the send button of a chat composer.

0/200

Theming

Token or attributeMeaning
h-controlThe 28 px group height; h-auto with a textarea or a block addon
rounded-chipThe 6 px control radius
bg-input/50The recessed field fill, on the group
data-alignThe addon's place: inline-start, inline-end, block-start, block-end
data-disabled="true" on the groupDims the addons
data-slotinput-group, input-group-addon, input-group-text, input-group-control

Accessibility

The group is a role="group". Name the input itself: an aria-label, or a FieldLabel when the group sits in a Field. An icon-only InputGroupButton needs an aria-label. A click on an addon's text or icon focuses the input; a click on its button doesn't.

API reference

InputGroup

Every <div> attribute.

InputGroupAddon

Every <div> attribute, plus:

Prop

Type

InputGroupButton

Every Button prop, plus:

Prop

Type

InputGroupInput, InputGroupTextarea

Every Input or Textarea prop, drawn borderless inside the group.

InputGroupText

Every <span> attribute.