Capítulo 36 de 43
A coordinated set of two-state buttons — supports both single-selection (radio-like) and multiple-selection modes, with roving-tabindex keyboard navigation between items.
Root → Item (one per button).type ("single" | "multiple"): single mode's value is a string; multiple mode's value is a string[] — the type itself changes shape based on this prop.rovingFocus (default true): whether Tab moves between items as one stop (roving tabindex) or each item gets its own tab stop.value/onValueChange and rejecting empty-value changes (only updating state when the new value is truthy) is the documented pattern for a toggle group that must always have one item selected — Radix doesn't enforce "always one selected" itself.const [value, setValue] = React.useState("left");
<ToggleGroup.Root
type="single"
value={value}
onValueChange={(v) => { if (v) setValue(v); }}
>
<ToggleGroup.Item value="left">Left</ToggleGroup.Item>
<ToggleGroup.Item value="center">Center</ToggleGroup.Item>
<ToggleGroup.Item value="right">Right</ToggleGroup.Item>
</ToggleGroup.Root>
type="single" as a segmented-control alternative to RadioGroup when you want button styling instead of radio dots; type="multiple" for independent-but-grouped toggles (e.g. text formatting: bold/italic/underline together).onValueChange if required, as shown above.rovingFocus follows the same roving-tabindex convention as RadioGroup/Tabs — disable it only if you specifically need every item individually tabbable.