A ToggleButtonGroup is a grouping of related ToggleButtons, with single or multiple selection.
Selection
Use the selectionMode prop to enable single or multiple selection. The selected toggle buttons can be controlled via the selectedKeys prop, matching the id of each <ToggleButton>. Toggle buttons can be disabled with the isDisabled prop. See the selection guide for more details.
Current selection: bold
API
<ToggleButtonGroup>
<ToggleButton />
</ToggleButtonGroup>
ToggleButtonGroup
| Name | Type | Default |
|---|---|---|
isEmphasized | boolean | Default: — |
Whether the button should be displayed with an emphasized style. | ||
styles | StylesPropWithHeight | Default: — |
Spectrum-defined styles, returned by the | ||
children | ReactNode | Default: — |
The children of the group. | ||
size | 'XS'
| 'S'
| 'M'
| 'L'
| 'XL' | Default: 'M'
|
Size of the buttons. | ||
density | 'compact' | 'regular' | Default: 'regular'
|
Spacing between the buttons. | ||
isQuiet | boolean | Default: — |
Whether the button should be displayed with a quiet style. | ||
isJustified | boolean | Default: — |
Whether the buttons should divide the container width equally. | ||
staticColor | 'white'
| 'black'
| 'auto' | Default: — |
The static color style to apply. Useful when the ActionButtonGroup appears over a color background. | ||
orientation | 'horizontal' | 'vertical' | Default: 'horizontal'
|
The axis the group should align with. | ||
isDisabled | boolean | Default: — |
Whether the group is disabled. | ||
selectionMode | 'single' | 'multiple' | Default: 'single'
|
Whether single or multiple selection is enabled. | ||
selectedKeys | Iterable | Default: — |
The currently selected keys in the collection (controlled). | ||
defaultSelectedKeys | Iterable | Default: — |
The initial selected keys in the collection (uncontrolled). | ||
onSelectionChange | | Default: — |
Handler that is called when the selection changes. | ||
disallowEmptySelection | boolean | Default: — |
Whether the collection allows empty selection. | ||
id | string | Default: — |
The element's unique identifier. See MDN. | ||
aria-label | string | Default: — |
Defines a string value that labels the current element. | ||
aria-labelledby | string | Default: — |
Identifies the element (or elements) that labels the current element. | ||
aria-describedby | string | Default: — |
Identifies the element (or elements) that describes the object. | ||
aria-details | string | Default: — |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
UNSAFE_className | UnsafeClassName | Default: — |
Sets the CSS className
for the element. Only use as a last resort. Use the | ||
UNSAFE_style | CSSProperties | Default: — |
Sets inline style for the
element. Only use as a last resort. Use the | ||
slot | string | null | Default: — |
A slot name for the component. Slots allow the component to receive props from a parent
component. An explicit | ||