Skip to content

ToggleGroup

A mutually exclusive button group for single/multiple selection: single mode uses radio semantics, multiple mode uses checkbox semantics; keyboard arrow navigation and controlled value.

Single Select

Without multiple, it is single-select (role="radiogroup" + radio); value is a string, and only one item is pressed at a time.

Single select

Current: day

Multiple Select

With multiple, it becomes multi-select (role="group" + checkbox); value is a JSON array string.

Multiple select

Current: []

Disabled

Item-level disabled: true disables that item; disabled items are skipped in keyboard navigation.

Disabled items

Controlled Selection (value)

value is a controlled channel: a string for single select, a JSON array string for multiple; externally setting the attribute immediately reflects in the selected state (clicks inside the group also write back the attribute). The buttons below drive the selection externally:

Controlled value

Single: DaySingle: MonthMultiple: Italic + Underline

Presetting value="week" / value='["bold"]' gives both groups an initial selected state; writing the value attribute externally switches the selected state immediately.

Events

Clicking or keyboard toggling dispatches oas-change; single select: detail: { value: string }, multiple select: detail: { value: string[] }.

Change events

oas-change: { value: "left" }

API

Attributes

AttributeDescriptionTypeDefault
itemsOptions JSON (property assignment reflects to attribute)ToggleItem[] | string[]
multipleMultiple mode (checkbox semantics)boolean
valueCurrent value: string for single; JSON array string for multiplestring[]

Events

EventDescription
oas-changeToggle, detail: { value: string | string[] }

ToggleItem fields:

FieldDescriptionType
labelButton labelstring
valueValue (returned with events)string
disabledDisable this itemboolean

Keyboard: in single mode arrow keys move and select (radio group convention); in multiple mode arrow keys move focus (roving tabindex) and Space/Enter toggle. The container has role="radiogroup" / role="group" + aria-label; selected items expose aria-checked.