4.2.0
Core

InputGroup

A control and everything attached to it — a leading icon, a trailing unit, an action, a strip above or below — inside one border.

Input group

One border around the control and everything attached to it, so the addons read as part of the field rather than as furniture beside it. The group owns the surface and the focus line; the control gives its own up — which is why the child is `InputGroupInput` and never a raw `Input`.

412 matches

Usage

import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
  InputGroupText,
  InputGroupTextarea,
} from '@oceanic-hub/brand-system'
<InputGroup>
  <InputGroupAddon>
    <InputGroupText>…</InputGroupText>
    <InputGroupButton>…</InputGroupButton>
  </InputGroupAddon>
  <InputGroupInput>…</InputGroupInput>
</InputGroup>

Composition

Use the following composition to build an InputGroup:

InputGroup
├── InputGroupAddon ×2
│   ├── InputGroupText
│   └── InputGroupButton
├── InputGroupInput
└── InputGroupTextarea

Reach for it when the attachment belongs to the field: the magnifier on a search box, the https:// a URL starts with, the unit a number is counted in, the clear button that empties what you just typed. If the thing beside the control is a separate command rather than part of the field, that is a ButtonGroup; if it is prose about the field, that is a FieldDescription.

Put InputGroupInput or InputGroupTextarea inside a group, never a raw Input or Textarea. Exactly one element in a field may own the field surface, and here it is the GROUP — it has to be, because the addons must sit inside the same box as the control or they read as furniture beside the field rather than part of it. So InputGroupInput is that same Input with its border, radius, ground and focus treatment stripped. Nest a raw one and you get a field inside a field; use InputGroupInput on a bare page and you get an invisible control. ButtonGroup is the mirror image — a raw Input is CORRECT there, because that group supplies no surface — and remembering which way round they go is easier than it looks: one border each.

align decides the shape, not just the position. inline-start and inline-end sit on the row with the control; block-start and block-end take a full line and turn the group into a column, which is how a hint strip or a character counter attaches to a textarea without drawing a second box around it.

Validity is stated once, by the control. Put aria-invalid on the InputGroupInput — where assistive tech reads it — and the group paints its own border stuck off that attribute. Disabling is the other way round: disabled on the control is the real thing, and data-disabled on the GROUP is what fades the addons with it, because an addon is not a form element and the native attribute cannot reach it.

Clicking an addon focuses the control — on an input. The handler looks for an <input> only, so a textarea group's addon shows a text cursor and moves nothing. Where it does fire, it fires because a reader who clicks the protocol prefix expects a caret; the handler stands aside over a button, so a clear or reveal action still acts. Your own onClick is called as well, not instead — worth knowing, because upstream's is replaced.

InputGroupButton is deliberately held to the 32px sizes — this package's touch floor — and they are literally Button's own rather than a re-declaration of them; upstream's 24px xs and icon-xs are refused, and an input group is precisely where a too-small target hurts, because the action sits inside the field.

Two upstream examples are refused rather than left silent. RTL is not supported — the package-wide refusal recorded in pairings.json under direction: nothing here has ever been laid out or measured right-to-left. And upstream's Custom Input example, which drops a third-party control into a group, is not ported: the group's FOCUS rule keys on a real input or textarea element, so a foreign control never lights the border, and one that draws its own gives you a field inside a field on a green build. The invalid rule is attribute-keyed and will still fire off aria-invalid, which is what makes the focus gap easy to miss — strip the control's surface yourself, and check focus as well as invalid, before trusting it.

Inline start

The default alignment: an icon or a fixed prefix on the leading edge of the row, ordered first whatever place it takes in the JSX. Reach for it when the reader needs to know what kind of value this is before typing one — a currency, a protocol, a search.

https://
€

Inline end

The trailing edge of the row, for what the value means once it has been typed: a unit, a domain, a count. order-last puts it there, so an addon declared before the control still lands after it and the JSX can read in whatever order explains the field best.

contacts / day
@acme.example

Block start

A block-start addon takes a full line above the control and turns the group into a column. Reach for it when what sits above the caret is part of the same field — the filters a query is already narrowed by, the recipients a message is already addressed to.

EU accountsReplied in 30dNo open task

Block end

The same full-width line, under the control instead of above it, which is how a counter and an action attach to an InputGroupTextarea without a second bordered box around them. The group grows to fit the textarea; nothing here sets a height.

84 / 280

Button

InputGroupButton is the package's Button at size="sm" — 32px, the touch floor — defaulting to ghost so a filled action does not compete with the field it sits inside. Reach for the labelled size when the action needs a verb; the glyph size, icon-sm, leads this page.

Keyboard hint

A Kbd in a trailing addon says how to reach the field without clicking it. The addon pulls a key cap tighter to the edge than it does an icon, because a cap already carries its own border and would otherwise sit a hairline too far in.

⌘K

With a menu

An addon can hold a menu trigger, which is how a field carries the one choice that changes what the typed value MEANS — a unit, a match mode, a column to search. The trigger is an InputGroupButton under asChild, so the menu opens from the field's own chrome.

Working

A Spinner in a trailing addon says the field itself is busy — checking a name, resolving a domain — without moving the caret or replacing the value. The mark keeps its shape under reduced motion, so the state survives the animation being switched off.

Invalid

The control states its own validity with aria-invalid and the group renders it — one source of truth, on the element assistive tech already reads. The line is a solid stuck border, not a soft ring: a translucent line reports a contrast number two to three times better than the one it actually draws, so it cannot be the thing carrying the state.

https://

Disabled

disabled on the control is the real thing — it is what stops the typing and what a screen reader announces. data-disabled on the GROUP is what fades the addons with it, because an addon is not a form element and the native attribute cannot reach one.

API Reference

See the InputGroup API page for every prop of every part, with types, defaults and the contract that pins them. It also documents inputGroupAddonVariants — exported alongside the parts, and signatures rather than props.

On this page