ToggleGroup
A row (or column) of Toggles that share one pressed style and one selection, single or multiple.
Toggle group
`type="single"` is a mutually-exclusive set — pressing one releases whichever was pressed before. `variant` and `size` set on the root flow to every item through context, so a caller writes them once for the whole set.
Usage
import { ToggleGroup, ToggleGroupItem } from '@oceanic-hub/brand-system'<ToggleGroup type="single">
<ToggleGroupItem value="…">…</ToggleGroupItem>
</ToggleGroup>Composition
Use the following composition to build a ToggleGroup:
ToggleGroup
└── ToggleGroupItem ×3This is the component that makes a set of Toggles behave as one control rather than
several unrelated buttons that happen to sit next to each other. Reach for it the moment
pressing one should matter relative to the others: mutually exclusive views (type="single")
or an independent multi-select toolbar (type="multiple") both live here, never as loose
Toggles.
type discriminates the value's shape: single takes a string, multiple an array. There
is no default to fall back on — an omitted type is a runtime error, not a defaulted
single-select, because without it the value's shape is unknowable.
variant and size set on the root flow to every item through context, so a caller writes
them once for the whole set. An item still accepts its own variant/size, but the
root wins where both are present — the context is read first, so an item's value only
lands when the group named none. That ordering is upstream's, and reversing it would break
<ToggleGroup size="sm"> over five items. The pressed style itself is not re-decided here —
ToggleGroup shares toggleVariants with Toggle, the same substitution of
bg-brand-soft for upstream's unaliased bg-accent, so the two components cannot drift
into disagreeing about what "on" looks like. See Toggle's own page for that argument in
full; this one is the shared-selection half.
Density is the group's own className, not a prop: a tighter gap-0.5 or a wider gap-2
replaces the default gap-1 outright — the same tailwind-merge composition Accordion's
bordered layout uses, and it is why there is no separate spacing axis to learn.
RTL is not supported, for the same reason as everywhere else in this package: nothing here
has been laid out or measured right-to-left. Recorded once, in pairings.json under
direction.
Upstream's Custom section ("a custom toggle group example") is not a separate demo here:
composing a fifth ToggleGroupItem or wiring one to a controlled value needs nothing this
page's own demos don't already show.
Multiple
type="multiple" is an independent multi-select — any number of items can be pressed at once, and pressing one leaves the rest exactly as they were. The value is an array here, the Radix shape; Base UI's multiple boolean is the mis-port the contract test pins against.
Outline
variant="outline" on the root — every item takes a border instead of the default's transparent rest state, the same substitution Toggle makes on its own for the same reason.
Sizes
Set once on the root and every item inherits it through context — the same sm / md / lg scale as Toggle, because the two share toggleVariants.
Vertical
orientation="vertical" switches Radix's roving focus to the up/down arrow keys; stacking the items is the group's own className, composed rather than a prop this component invents.
Disabled
disabled on one item takes it out of the roving selection without hiding it; on the whole group it fades every item at once, for a set that is temporarily not this reader's to change.
Pill row (segmented control)
shape="pill" on the root turns the group into a segmented control — the shape the Paid media surface uses for its second tab level (campaign types), below a Tabs underline row for sections. A disabled item composes a trailing Badge for free: ToggleGroupItem already takes any children, and disabled puts it outside the accessibility tree's focus order with no aria-disabled needed.
API Reference
See the ToggleGroup API page for every prop of every part, with types, defaults and the contract that pins them.