OGE logoOGE

Button Group

<oge-button-group> lays out buttons as one segmented control and optionally tracks selection. Children inherit the group's stylingMode, severity and size; arrow keys move focus with a roving tabindex — in single mode they move the selection too, exactly like a radio group.

selectionMode [(selectedKeys)] items roving tabindex

Single selection (radio pattern)

One segment stays selected at all times, exactly like a radio group: the group takes role='radiogroup', children become role='radio' with aria-checked, and arrow keys move focus and selection together. selectedKeys is a two-way model, so presets and programmatic changes flow both ways.

single = radiogroup arrows select
selected: left

Multiple selection (toggle buttons)

Each segment toggles independently (aria-pressed semantics) — the classic text-formatting toolbar. selectionChanged reports the full state plus addedKeys/removedKeys diffs, so you never have to compute what changed.

multiple = toggle buttons aria-pressed
active: bold

Data-driven items

When the segments come from data, pass an items array instead of (or in addition to) declarative children — each entry carries value, text, optional hint/disabled/severity/badge. The group's stylingMode, severity and size cascade into every child unless the child overrides them.

data-driven [items] cascaded size
period: week

Notes

  • Roles adapt to the mode: toolbar (none), radiogroup + role="radio" children (single), group + aria-pressed children (multiple).
  • Declarative children and the items array can be mixed; items render after the projected buttons. Icons need declarative children.
  • selectedKeys always receives a fresh array — safe for OnPush change detection and computed() consumers.
  • A group-level disabled disables every child; individual buttons can still opt out of selection by omitting value.