Single- or multiple-selection collection of toolbar-style toggle buttons.
Install @wyrd-company/react or the Flutter package and use it directly —
your DESIGN.md does the styling.
catalog/contracts/toggle-group.ymlsource of truth · verbatim
$schema: https://thewyrdingway.dev/schemas/component-contract.schema.ymlcontractVersion: 0.1.0identity:name: ToggleGrouptag: wyrd-toggle-grouppackage: wyrd.component.toggle-grouptitle: Toggle Groupsummary: Single- or multiple-selection collection of toolbar-style toggle buttons.relationships:related-to: - collection-navigation - quality-parity-and-gatesclassification:category: actioncomposition: collectioninteractive: truetarget-strategy:react: requiredflutter: requiredsurface:properties: - name: labeltype:kind: stringrequired: trueserializable: truesummary: Accessible name for the toggle group. - name: typetype:kind: enumvalues: - single - multiplerequired: falsedefault: singlereflects: trueserializable: truesummary: Whether activation selects one item or independently toggles many items. - name: valuestype:kind: arrayitem:kind: stringrequired: falsecontrolled: trueserializable: truesummary: Controlled selected item values; single mode uses at most one value. - name: default-valuestype:kind: arrayitem:kind: stringrequired: falsedefault: []serializable: truesummary: Initial uncontrolled selected item values. - name: itemstype:kind: arrayitem:kind: objectfields:value:kind: stringlabel:kind: stringdisabled:kind: booleanrequired: falsedefault: []serializable: truesummary: Ordered toggle button items; disabled items render but are skipped by navigation and activation. - name: is-disabledtype:kind: booleanrequired: falsedefault: falsereflects: trueserializable: truesummary: Prevents navigation and selection changes for the collection.slots: []events: - name: values-changepayload:values:kind: arrayitem:kind: stringaction:kind: action-refbubbles: truecomposed: truecancelable: falsesummary: Canonical event carrying the complete requested selected values array.states: - name: defaultsource: platformsummary: Enabled collection. - name: pressedsource: propertysummary: Persistent selected state on one or more items. - name: focus-visiblesource: platformsummary: Keyboard-visible focus on the roving item. - name: disabledsource: propertysummary: Disabled collection or item state.parts: - name: rootsummary: Toggle collection group root. - name: itemsummary: Repeated native pressed button.tokens:item:background: color.surfaceforeground: color.on-surfacebackground-hover: color.secondarypressed-background: color.secondarypressed-foreground: color.on-secondarydisabled-background: color.disableddisabled-foreground: color.on-disabledpadding-x: spacing.mdpadding-y: spacing.smradius: rounded.mdgap: spacing.xslabel: typography.label-mdmessages: []obligations:accessibility:role: groupname: Consumer-provided aria-label or surrounding labelled context names the group.keyboard: - In single mode, Tab moves focus into the roving enabled item and out of the group. - In single mode, ArrowLeft and ArrowRight move focus between enabled items with wrap-around and follow visual direction in RTL. - In single mode, ArrowUp and ArrowDown move focus between enabled items with wrap-around. - In single mode, Home and End move focus to the first and last enabled items. - In multiple mode, Tab moves through every enabled item in natural document order. - Enter and Space toggle the focused enabled item.semantics: - Web projections expose role=group with the required label property applied as aria-label, and native buttons with aria-pressed. - Single mode maintains at most one pressed item; activating the pressed item clears selection. - Multiple mode exposes independent pressed states. - Disabled items are skipped by single-mode roving focus and cannot be activated.behavior:model: collectioninteractions: - values wins over default-values when provided. - Single mode activation replaces selection with the item value or clears an already selected item. - Multiple mode activation adds or removes the item value while preserving item order. - In single mode, arrow and boundary keys move focus without changing selection. - In multiple mode, items use natural tab order and arrow keys are not handled. - Controlled activation emits values-change without mutating controlled values.hostEffects: - Use the shared collection behavior primitive for roving focus navigation. - Dispatch values-change after accepted activation.conditions: - rtl - reduced-motion - cvd-deuteranopia - density-compact - text-expansionsdui:status: serializableserializableProperties: - label - type - values - default-values - items - is-disabledserializableSlots: []eventBindings: - values-changenotes: Items serialize as ordered records; the group owns selection and roving focus while each item retains pressed-button semantics.examples: - name: singlestate: pressedproperties:label: Text alignmenttype: singledefault-values: - centeritems: - value: leftlabel: Align left - value: centerlabel: Align center - value: rightlabel: Align rightslots: {} - name: multiplestate: pressedproperties:label: Text formattingtype: multipledefault-values: - bold - italicitems: - value: boldlabel: Bold - value: italiclabel: Italic - value: underlinelabel: Underlineslots: {} - name: disabled-itemstate: disabledproperties:label: Text alignmentitems: - value: leftlabel: Align left - value: centerlabel: Align centerdisabled: true - value: rightlabel: Align rightslots: {}
01
Examples
Generated from the contract's examples block.
Previews are the published @wyrd-company/react component, themed by the
brand's role tokens — flip the site's light/dark toggle and they follow.
Whether activation selects one item or independently toggles many items.
values
array
undefined
Controlled selected item values; single mode uses at most one value.
default-values
array
Initial uncontrolled selected item values.
items
array
Ordered toggle button items; disabled items render but are skipped by navigation and activation.
is-disabled
boolean
false
Prevents navigation and selection changes for the collection.
03
Slots & events
Event
Payload
Summary
values-change
values, action
Canonical event carrying the complete requested selected values array.
04
Tokens
The contract's token bindings. Open the shared contextual sidebar from any example;
primary swatches reflect the color you pick there. Error swatches show the active
preset's values; editing any knob switches to custom and resets error to TWW · Ink.
Binding
Token
item.background
color.surface
item.foreground
color.on-surface
item.background-hover
color.secondary
item.pressed-background
color.secondary
item.pressed-foreground
color.on-secondary
item.disabled-background
color.disabled
item.disabled-foreground
color.on-disabled
item.padding-x
spacing.md
item.padding-y
spacing.sm
radius
rounded.md
gap
spacing.xs
label
typography.label-md
05
States
State
Source
Summary
default
platform
Enabled collection.
pressed
property
Persistent selected state on one or more items.
focus-visible
platform
Keyboard-visible focus on the roving item.
disabled
property
Disabled collection or item state.
06
Accessibility
From the contract's accessibility obligations. Role group; Consumer-provided aria-label or surrounding labelled context names the group.
In single mode, Tab moves focus into the roving enabled item and out of the group.
In single mode, ArrowLeft and ArrowRight move focus between enabled items with wrap-around and follow visual direction in RTL.
In single mode, ArrowUp and ArrowDown move focus between enabled items with wrap-around.
In single mode, Home and End move focus to the first and last enabled items.
In multiple mode, Tab moves through every enabled item in natural document order.
Enter and Space toggle the focused enabled item.
Web projections expose role=group with the required label property applied as aria-label, and native buttons with aria-pressed.
Single mode maintains at most one pressed item; activating the pressed item clears selection.
Multiple mode exposes independent pressed states.
Disabled items are skipped by single-mode roving focus and cannot be activated.