Several toggles, one value array, wrapping the Base UI Toggle Group. The natural fit for toolbars: formatting marks, alignment, view switches.

Playground

Every control maps to a prop. The Code tab always shows the markup for exactly what you've configured.

Variants

Single-select (alignment: one at a time) beside multiple (formatting: any combination), in both sizes. Size lives on the toggles, not the group.

States

Pressed and unpressed belong to the toggles; disabled on the group dims every member. Arrow keys move focus along the group, and in single-select mode pressing the active toggle again unpresses it, so the value can become an empty array.

Styling states

The group is a plain flex container, .ub-toggle-group, carrying data-multiple when several can be pressed and data-disabled when switched off; the toggles keep their own data-pressed. A segmented look is a few lines:

.ub-toggle-group {
  gap: 0;
  padding: 0.125rem;
  border-radius: var(--ub-radius-control);
  background: var(--ub-bg-muted);
}

.ub-toggle-group .ub-toggle[data-pressed] {
  background: var(--ub-bg);
  box-shadow: var(--ub-shadow-sm);
}

Props

The group passes the full Base UI API through, and the toggles inside are regular Bones Toggles. The essentials:

PropTypeDefaultDescription
defaultValuestring[]Pressed values on first render, when uncontrolled.
valuestring[]Controlled pressed values. Pair with onValueChange.
onValueChange(value: string[]) => voidCalled with the new array when any toggle changes; empty when nothing is pressed.
multiplebooleanfalseAllow several pressed at once instead of single-select.
disabledbooleanfalseDisables every toggle inside.
Toggle.valuestringJoins the toggle to the group under this value.

Agent instructions

Working with a coding agent? Paste this into its context, or point it at llms.txt for the whole library.

ToggleGroup, from @usebones/react.
- Wraps Bones Toggles; each joins via value="...". Group state is a string array: defaultValue or value + onValueChange.
- Single-select by default (alignment); multiple for independent toggles (formatting marks). Single-select can still unpress to []; control value if one must stay pressed.
- Size goes on each Toggle (size="compact"); the group has no size prop. disabled on the group disables every member.
- Restyle in CSS via .ub-toggle-group, [data-multiple], [data-disabled]; the toggles style themselves via [data-pressed]. Tokens only.