Repository navigation
Description
Summary
ToggleButtonGroup manages a set of toggle buttons (single/multiple select) but does not implement roving tabindex — so every toggle button is its own tab stop (the same keyboard a11y anti-pattern we're fixing elsewhere, e.g. AvatarGroup #4170). It should be a single tab stop with arrow-key navigation across its buttons. Fixing this cleanly runs into a design question about how it relates to ButtonGroup (connected visuals) and SegmentedControl (radio semantics), which this issue should settle.
Current state (grounded in source)
ToggleButtonGroup(packages/core/src/ToggleButton/ToggleButtonGroup.tsx):role="group"+aria-label, discriminatedtype: 'single' | 'multiple',orientation. NouseListFocus, no roving tabindex → N tab stops. No connected/unconnected visual treatment.ButtonGroup(packages/core/src/ButtonGroup/ButtonGroup.tsx): already does BOTH the connected visual ("shared borders, border-radius only on outer edges") AND roving viauseListFocus. It's a generic button grouper, not toggle-state-aware.SegmentedControl(packages/core/src/SegmentedControl/SegmentedControl.tsx): the radio-group model —role=radiogroup/radio,useListFocus({hasRovingTabIndex: true}), selection-follows-focus (APG radiogroup). Single-select, connected visual.
The tension
- ToggleButtonGroup needs roving tabindex (single tab stop) — this part is table stakes; reuse the shared
useListFocus({hasRovingTabIndex})primitive (as SegmentedControl/AvatarGroup/ButtonGroup do). - The connected visual (shared borders / outer-edge radius) currently lives in
ButtonGroup— butButtonGroupalso owns roving. So if you compose ToggleButtonGroup on top of ButtonGroup to get the visual, you get two roving layers fighting each other. Visual and focus-management are entangled inButtonGrouptoday.
Design options (pick one — this issue decides)
Option A — decouple visual from behavior via a connected/unconnected variant.
Add a visual variant (e.g. variant: 'connected' | 'separate', or isAttached) to ButtonGroup/ToggleButtonGroup so the connected styling can be applied independently of who owns roving. Then ToggleButtonGroup owns its own roving (single/multiple aware) and opts into the connected visual without inheriting ButtonGroup's focus management. Likely requires extracting ButtonGroup's connected-styling into something reusable that doesn't also wire roving.
Option B — make ToggleButtonGroup more like SegmentedControl / RadioList.
For the single-select case, lean into radiogroup semantics + owned roving (SegmentedControl already is this — is single-select ToggleButtonGroup redundant with it?). Clarify the boundary: SegmentedControl = single-select segmented radios; ToggleButtonGroup = multi-select (and/or non-radio single) toggles. ToggleButtonGroup gets the same useListFocus roving, with role/selection semantics appropriate to single vs multiple (single → radiogroup-like; multiple → group of toggle buttons with arrow nav).
Considerations for either:
- Roving must handle both
type='single'andtype='multiple'(multiple isn't a radiogroup — it's a toolbar-ish group of independent toggles; arrow-nav + roving still apply, but ARIA differs from radio). - Reuse
useListFocus({hasRovingTabIndex})and the existing connected-styling — don't reimplement either. - Avoid double-roving: exactly one layer owns the single tab stop.
- Respect
orientation(arrow axis) and disabled-skip, matching SegmentedControl. - Non-breaking where possible; if single-select ToggleButtonGroup overlaps SegmentedControl, document the intended boundary rather than silently duplicating.
Acceptance (post-design)
- ToggleButtonGroup is a single tab stop with arrow/Home/End roving across its buttons (both single and multiple), via the shared primitive.
- A decided answer on connected-vs-unconnected visuals (a variant that decouples styling from focus management, or a SegmentedControl-aligned model) — with the ButtonGroup/SegmentedControl boundary documented.
- Correct ARIA per selection mode; disabled-skip; non-breaking default; spec reviewed before build.
Activity
AKnassa commentedon Aug 9, 2026
One correction before this gets scoped: ButtonGroup doesn't own roving tabindex. It calls
useListFocuswithouthasRovingTabIndex(ButtonGroup.tsx:173-176), so it writes notabindexat all. Three Buttons is three tab stops, with arrow nav on top. So there's no "two roving layers" conflict to design around, just two arrow handlers, and ToggleButtonGroup needs its own roving either way.On the visual:
Button.tsx:687-699already keys the connected styling offuseButtonGroup()alone, so nothing needs extracting. The catch is the container. ButtonGroup has no gap, ToggleButtonGroup hasgap: --spacing-1, so aconnectedvariant would also need to drop the gap, switchalign-items, and decide what happens topressableand elevation (both!buttonGroup &&gated). Cheaper than Option A assumes, but not free.Two smaller notes. For Option B, the blockers are that radios don't deselect on re-click (
ToggleButtonGroup.tsx:213) and APG selection-follows-focus would make arrows fireonChange. AndisDisabledon a ToggleButton inside a group currently has no effect (ToggleButton.tsx:254), so disabled-skip has nothing to skip yet.Happy to put up the roving half if that's useful, it's built and tested against main.