Live demo
Demo source
A toggle button group joins toggle buttons and keeps the selected values as a
string array in value; each button's value names its option.
exclusiveallows one choice; without it, several buttons can be selected.enforceValuekeeps at least one button selected.emphasisandsizeapply to every button in the group.- Bind
valueand listen forvalueChanged. Name the group withrole="group"and anaria-label.
Anatomy
The toggle button anatomy shows text and icon-only buttons together in a group.
Appearance and states
This component implements the grouping described on the Togglegroup design
page. Its child toggle buttons can use
text, icons or both in their default slot. Use the same emphasis (high or
low) and size (xs, sm, md or lg) throughout the group.
Spark and Ocean provide default, hover, focus, selected and disabled styles.
Set disabled on individual children when those options are unavailable;
the group has no group-wide disabled prop. Keep each option's label and focus
indicator clear, including an aria-label for an icon-only toggle.
Selection guidance
Use exclusive for mutually exclusive views, such as list or grid. Leave it
off for independent choices, such as several text-formatting options. Set
enforceValue when clearing the last choice would leave an invalid state.
The group updates the children's active state from its value array;
consumers should bind that array instead of independently setting child
selection. Choose labels that describe the state being turned on.