Input Group

An input or textarea with icons, text, or buttons inside its border

Composablebuilt onInput

An input group puts icons, text, and buttons inside a field's border, like a search icon, a unit suffix, or a show-password button. Buttons sit in the field's corners with an even 2px gap.

For a number with step buttons, use NumberField. To join a field to buttons outside it, use ButtonGroup.

Preview

12 results
https://
52% used

Installation

Usage

Composition

Set each addon's side with align; a button on an inline addon's outer edge fits into the field's corner.

Examples

Password Toggle

Use InputGroupButton with size="icon" for an icon button in the field.

With Suffix

Use align="inline-end" for units and currency codes.

USD
kg

Keyboard Shortcut

Put a Kbd in an addon to show a shortcut.

⌘K

Size

Use size to match an Input of the same size; buttons inside follow.

Validation

Set aria-invalid on the input to put the error ring on the group.

Elevated

Use variant="elevated" inside a Card, Dialog, or popover; see Surfaces.

On a Card surface
Use variant="elevated" on the InputGroup when it sits inside a Card, Dialog, or popover.
VariantDescription
defaultOpaque fill for the page.
elevatedTranslucent fill for Cards, Dialogs, and popovers.

Accessibility

Labels

The group renders role="group"; label the input itself with Label or FieldLabel. Give every icon-only button an aria-label.

Addons

Clicking an addon's icon or text focuses the input or textarea; its buttons and links keep their own focus. Addon text isn't part of the input's name, so repeat a unit like "kg" in the label if it matters.

API Reference

Input Group is a custom component built from plain HTML elements and Input, Textarea, and Button; every prop below is specific to it. Each part also accepts the props of what it renders.

Props

InputGroup

The field's border and fill. Renders a div with role="group".

InputGroupAddon

Icons, text, or buttons beside the input. Renders a div.

InputGroupButton

A button for an addon. Wraps Button.

Notes

InputGroupInput / InputGroupTextarea

Wrap Input and Textarea without their border and fill, which the group draws.

InputGroupText

Muted text for an addon, like a prefix or a count. Renders a span.

Upgrading

If you're reinstalling over an earlier version, check these changes:

BeforeNow
The group was 2px taller than an InputIt matches Input's height. Set size="sm" to match a small one.
InputGroupButton sizes xs and smsize="default".
InputGroupButton sizes icon_xs, icon_smsize="icon".
Inline buttons floated with their own cornersThey fill the field's height with corners concentric to it; drop rounded-full overrides.
Clicking an addon focused only an inputIt focuses a textarea too.