ToggleGroup

A compact group of toggle buttons for independent or optional pressed states.

Preview#

import { ToggleGroup, ToggleGroupItem, ToggleGroupLabel } from "raft-ui";

<ToggleGroup multiple defaultValue={["bold"]} aria-label="Text formatting">
  <ToggleGroupItem value="bold">
    <ToggleGroupLabel>Bold</ToggleGroupLabel>
  </ToggleGroupItem>
</ToggleGroup>

Use ToggleGroup when an item may be toggled off. Use SegmentedControl for a persistent one-of-many value that changes a view, filter, or mode.

One or none#

API#WIP

value
readonly T[]
Pressed item values for controlled use.
defaultValue
readonly T[]
Initially pressed item values for uncontrolled use.
onValueChange
(value: T[], eventDetails: ToggleGroup.ChangeEventDetails) => void
Called when the pressed item collection changes.
multipledefault: false
boolean
Allows more than one item to stay pressed.
orientationdefault: "horizontal"
"horizontal" | "vertical"
Controls visual layout and arrow-key navigation.
loopFocusdefault: true
boolean
Wraps roving keyboard focus at either end of the group.
disableddefault: false
boolean
Disables every item in the group.
...props
Base UI ToggleGroup.Props<T>
Native div attributes, render substitution, styling, and ARIA labeling.
value
T
Required unique value tracked in the parent group's pressed collection.
disableddefault: false
boolean
Disables this item without disabling its siblings.
onPressedChange
(pressed: boolean, eventDetails: Toggle.ChangeEventDetails) => void
Per-item callback fired when this item's pressed state changes, before the group's onValueChange. Use eventDetails.cancel() to reject a single item's press.
...props
ToggleGroupItemProps<T>
Base UI Toggle props without standalone pressed/defaultPressed state, plus a required value.
...props
ComponentPropsWithRef<"span">
Visible item label with truncation and native span attributes.