ToggleButtonGroup
A toggle button group allows a user to toggle multiple options, with single or multiple selection.
Theme
selectionMode
orientation
isDisabled
Selection
Use the selectionMode prop to enable single or multiple selection. The selected items can be controlled via the selectedKeys prop, matching the id of each <ToggleButton>. Items can be disabled with the isDisabled prop. See the selection guide for more details.
Current selection: bold
selectionMode
disallowEmptySelection
Animation
Render a SelectionIndicator within each ToggleButton to animate selection changes.
Example
SegmentedControl.css
Example
SegmentedControl.css
Example
SegmentedControl.css
import {ToggleButtonGroup, ToggleButton, ToggleButtonProps, SelectionIndicator} from 'react-aria-components';
import './SegmentedControl.css';
function SegmentedControlItem(props: ToggleButtonProps) {
return (
<ToggleButton {...props} className="segmented-control-item">
<SelectionIndicator className="react-aria-SelectionIndicator button-base" data-selected />
<span>{props.children}</span>
</ToggleButton>
);
}
<ToggleButtonGroup
className="segmented-control button-base"
data-variant="secondary"
defaultSelectedKeys={['day']}
disallowEmptySelection>
<SegmentedControlItem id="day">Day</SegmentedControlItem>
<SegmentedControlItem id="week">Week</SegmentedControlItem>
<SegmentedControlItem id="month">Month</SegmentedControlItem>
<SegmentedControlItem id="year">Year</SegmentedControlItem>
</ToggleButtonGroup>