Skip to content

React Input Group Component

A React input group that attaches text, icons or buttons to a field and shares one focus ring. Use InputGroup when one field needs things attached to it: an https:// prefix, a .com suffix, a currency or unit, or a button such as Apply inside the same edge.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/input-group.json

Share your page

https://

Type an address, then copy it.

  • InputGroup
  • InputGroupText
  • InputGroupAddon
  • InputGroupInput
  • +2 more

Using it in a form? See the react-hook-form and zod recipe.

Prefix, suffix, unit and button

Compose InputGroupAddon and InputGroupInput in reading order. Use Input's leading and trailing for a single icon.

https://
.com
USD

Files to copy

3 folders · 2 files · 4 packages
From theme/src/
  • components/input-group/
  • lib/{cn.ts, field-size.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/input-group.jsonRegistry item: input-group. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/button/
  • components/field/
  • components/spinner/
  • hooks/{use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{form.ts, state-light.tsx}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/field.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Inside a Field

Field wires the label, the description and the error to the input: wrap the InputGroupInput in FieldControl, and set invalid on both the Field and the group so the danger edge and the message agree.

example.com/

InputGroup props

PropTypeDefaultDescription
childrenReactNodeNoneInputGroupAddons and one InputGroupInput, in reading order.
sizeFieldSize"md"Height, the same scale as Button and every field: "sm" 32px, "md" 40px, "lg" 48px (sm and md are 44px on touch screens).
invalidbooleanfalseMark the group invalid (danger edge). Pair it with aria-invalid on the input.
disabledbooleanfalseDim the group; disable the input yourself.

InputGroupAddon props

PropTypeDefaultDescription
align"end" | "start""start"Which end of the field it sits on: "start" (before the input, default) or "end". It only changes the divider side: put the addon where you want it in the markup (DOM order is the reading order and the visual order).

Other parts

PropTypeDefaultDescription
InputGroupTextspan propsNoneShows plain text inside an addon.
InputGroupInputinput propsNoneThe text field, as tall as the group, forwarding ref.

Keyboard

KeysAction
TabFocuses the input, then any button inside an addon.
TypingWorks as in any text input; the addons are not focusable text.

Accessibility

  • The group is role="group". Name the input with aria-label or a Field label: addon text is read as part of the page but is not the input's name unless you link it with aria-describedby.
  • invalid shows the danger edge; set aria-invalid on the input too, so the state is not carried by colour alone.
  • Icons in an addon should be aria-hidden; text such as https:// is read in order with the field.
  • Height follows the shared control scale (sm 32px, md 40px, lg 48px; 44px for sm and md on touch screens).

When to use the input group

  • Use InputGroup for a URL field with an https:// prefix, a price with a currency symbol and a unit, or a search box with an Apply button on its right edge, all sharing one focus ring.
  • Compose InputGroupAddon and InputGroupInput in reading order. Use align end on an addon that follows the input, and put it after the input in the markup.
  • Wrap the input in Field with FieldControl when it needs a label, a description or an error message, and set invalid on the Field and the group together.
  • Skip it for a single icon inside a plain field. Input has leading and trailing slots for that.
  • Pair it with Button for an inline action, Tooltip on an icon-only addon, and Select when the addon is a currency or unit picker.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .