4.2.0
Core

ButtonGroup

Controls welded into one, so the seam between neighbours collapses to a single line — a segmented switcher, a split button, a field with its own prefix.

Default

Buttons welded into one control: the seam collapses the two 1px borders between neighbours into one and squares the corners that meet, so a row of 6px buttons reads as a single control with rounded ends. A segmented switcher, a split button and a static prefix are three shapes of the same grammar.

Segmented
Split button
Static segment

Usage

import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from '@oceanic-hub/brand-system'
<ButtonGroup>
  <ButtonGroupSeparator>…</ButtonGroupSeparator>
  <ButtonGroupText>…</ButtonGroupText>
</ButtonGroup>

Composition

Use the following composition to build a ButtonGroup:

ButtonGroup
├── ButtonGroupSeparator
└── ButtonGroupText

A ButtonGroup supplies no surface of its own; it only collapses the borders between its children and squares the corners that meet. What can go inside, and why, is the part a type cannot say:

  • Button — any variant, any size, as long as every sibling agrees on the size. The seam collapses two 1px borders into one; it cannot reconcile two heights.
  • ButtonGroupText — a static segment: a protocol, a unit, a currency, a <label> (pass asChild).
  • ButtonGroupSeparator — only where the collapsed border is not enough, i.e. a split button whose two halves do different things.
  • a bare Input — yes, and this is the one worth knowing precisely because it looks interchangeable with something that is not: the base carries [&>input]:flex-1 and squares the corners of any child, so a plain Input welds in correctly, keeping its own border and surface. InputGroupInput does not work here — it has had its border and ground stripped because an InputGroup supplies them, and a bare ButtonGroup does not, so it would render as a hole in the row. A nested whole InputGroup is how the two families compose instead, and it gets the same air between clusters that two nested ButtonGroups do below — both are read off the same role="group".

orientation="vertical" squares the top and bottom corners instead of the left and right ones, and drops the top border rather than the left.

This is a hand-translation, not a port: upstream's file is served from the classic new-york path but is v4 source — the mixed-generation case composition.md §3 warns about — so it has no ancestor in our Radix generation, and where the two disagree, ours is the API — most of what upstream also shows (dropdown menu, select, popover as the trailing segment) is the same split-button grammar with a different last child, so it is not repeated here as separate pages.

Sizing is not this component's axis. The "Size" upstream shows is Button's own sm / md / lg scale, reused — see that component's page, not this one.

This is a visual weld only; it holds no selection state. When exactly one control (or a set) being "pressed" is meaningful and must be tracked, reach for ToggleGroup instead — a segmented-looking row of plain Buttons here is decoration, and the caller owns the state.

RTL is not supported, and upstream ships an RTL example. Nothing in this package has been laid out or measured right-to-left, so the refusal is written down in pairings.json under direction rather than left to be discovered.

Vertical

orientation="vertical" squares the top and bottom corners instead of the left and right ones, and drops the top border rather than the left — for an action stack rather than a toolbar row.

Nested groups

A group whose children are themselves groups gets air between the clusters — the base reads role="group" on its own children to tell the two cases apart, which is why a nested cluster needs no marker prop. The same rule is what lets a ButtonGroup sit beside a whole InputGroup.

API Reference

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

On this page