Toggle Group
A set of toggle buttons where one or several can be pressed.
Usage
ToggleGroup lays out a row of Toggles and tracks which ones are pressed as a string array of their values. It's single-select by default — pressing one toggle releases the previous — and becomes multi-select with the multiple prop, where any number of toggles can stay pressed at once. Drive it uncontrolled with defaultValue, or controlled with value + onValueChange.
Toggle ships no styling of its own, so give each one a look by composing it with Button through render={<Button … />} — Button already reacts to data-pressed, so the pressed state comes for free. Because a toggle group is a role="group" rather than a labelable form control, name it with aria-label or aria-labelledby — never with a <Field>/FieldLabel.
Examples
Single selection
By default the group is single-select: pressing a toggle releases whichever one was pressed before, so exactly one stays active.
Multiple selection
Add multiple to let several toggles stay pressed at once — handy for independent formatting options like bold, italic, and underline.
Vertical orientation
Set orientation="vertical" to stack the toggles in a column. Arrow-key focus follows the same axis.
Disabled
Set disabled on the group to disable every toggle inside it at once.
Color swatches (controlled)
A controlled single-select group, used as a color picker. Here the toggles aren't button-shaped, so they're styled directly rather than composed with Button — each bare Toggle is a 16px circular swatch carrying its color, and the pressed one gets an offset border-inverse ring. Driving it with value + onValueChange keeps the selection in state, which the label above reads to name the current color.
RTL
Every Appica UI component supports right-to-left layouts out of the box. Set the dir attribute on a container (commonly your <html> element) so CSS logical properties resolve correctly, and wrap your tree in DirectionProvider so direction-aware behavior — roving focus, popup placement, and the like — follows the same direction.
The toggles align to the start edge and arrow-key focus follows the resolved direction, so the first toggle sits on the right under RTL. For setup details and caveats, see the RTL guide.
API reference
ToggleGroup wraps Base UI's Toggle Group, renders with role="group", and forwards ref and every remaining <div> attribute. Its children are Toggles — each needs a value and an accessible name. To present a standalone toolbar, pass role="toolbar" yourself (don't nest one inside Toolbar, which is already a toolbar).
Accessibility
- The group renders as a
role="group", so name it witharia-labeloraria-labelledby— not a<Field>/FieldLabel, whose<label for>doesn't associate with a group. - Arrow keys move focus between toggles via roving tabindex (the row has a single tab stop), following the group's
orientation;loopFocuscontrols whether focus wraps at the ends. - Space or Enter toggles the focused button, which exposes its pressed state through
aria-pressed. - Setting
disabledon the group disables all of its toggles, removing them from the tab order.