Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Toggle Group
  3. API and Development

Toggle group

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
ToggleGroupRoot wraps ToggleGroup.Item children as a mutually exclusive selection (type="single"). ToggleGroupItem renders a button with vertical separators and Text labels. Sizes: ToggleGroupSize.Small, Medium, Large (default).
ToggleGroupRoot
NameTypeDefaultDescription
aria-descriptionLocalizedMessage—Extended description for assistive tech.
aria-labelLocalizedMessage—Accessible name when the visible label is insufficient.
aria-labelledbystring—Id of the element that names this group; use {@link ToggleGroupLabelledByProps} instead. Id of the element that names this group.
aria-placeholderLocalizedMessage—Hint for an empty control.
childrenReactNode—Toggle parts. Each must be a {@link ToggleGroupItem }.
classNamestring—Optional module class from colocated CSS.
collapseUnselectedLabelsboolean—Collapses unselected items to their icon and animates the selected label open. Items need {@link ToggleGroupItemProps.icon} and aria-label or visible button copy.
defaultValueDisplayValue | DisplayValue[] | null—Initial selected id when uncontrolled. Initial selected ids when uncontrolled.
disabledboolean—Disables every item.
fullSpanboolean—When true, items span the full width of the parent evenly.
initialItemIdDisplayValue—Item id that receives tabIndex={0} when nothing is selected and no item has focus yet.
labelLocalizedMessage—Accessible name for the group (role="group"). Accessible name prop; use {@link ToggleGroupLabelProps} instead.
loopboolean—Whether arrow keys wrap at the ends. Defaults to true.
onBlurFocusEventHandler<HTMLElement>—Called once when focus leaves the whole group for somewhere outside it, such as the next field. It is not called when focus moves between items, so a form library validates on blur once per visit.
onFocusFocusEventHandler<HTMLElement>—Called once when focus enters the group from outside it. It is not called when focus moves between items. Use it with onBlur to track whether the field was touched.
onValueChange((value: DisplayValue | null, details: ChangeDetails<ChangeReason>) => void) | ((value: DisplayValue[], details: ChangeDetails<ChangeReason>) => void)—Called when the selection changes. details.reason is {@link ChangeReason.ItemPress } for pointer and Enter/Space activation on an item.
orientationToggleGroupOrientation—Main-axis layout. Defaults to {@link ToggleGroupOrientation.Horizontal}.
refRef<HTMLDivElement>—Ref to the group element.
sizeToggleGroupSize—Item height; feeds each {@link Button } child size. Defaults to {@link ToggleGroupSize.Large}.
titleLocalizedMessage—Native tooltip; accessibility hint, not visible UI title text.
typeToggleGroupType—Selection mode. Defaults to {@link ToggleGroupType.Single}. Multi-select mode.
valueDisplayValue | DisplayValue[] | null—Selected item id when controlled. Selected item ids when controlled.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
ToggleGroupRoot props
PropDefaultDescription
collapseUnselectedLabelsfalseAnimates unselected items down to their icons. Every collapsible item must provide icon and aria-label.
ToggleGroupItem
NameTypeDefaultDescription
valuestringrequiredStable id for selection.
disabledbooleanfalseDisables one option.
childrenReactNoderequiredVisible label.
iconIcon—Leading icon; required for items that collapse under collapseUnselectedLabels.
aria-labelLocalizedMessage—Accessible name; required when the label collapses to an icon. Pass formatMessage output.
Default
Controlled
Sizes
Icons
Collapse unselected labels
Lead icon and text
ToggleGroup vs SegmentedControl
Previous
Toggle Group / Usage
Next
Toggle Group / Accessibility
On this page
ToggleGroupRoot
Storybook
ToggleGroupRoot props
ToggleGroupItem
Default
Controlled
Sizes
Icons
Collapse unselected labels
Lead icon and text
ToggleGroup vs SegmentedControl