ToggleGroup

A segmented group of toggle buttons where one item (single mode) or many items (multiple mode) can be active at once.

Installation

npx dafink-ui add toggle-group

Demo

Composition

<ToggleGroup>
<ToggleGroupItem />
</ToggleGroup>

Props

NameTypeDefaultDescription
type"single" | "multiple"-Controls whether one or many items can be active at once.
valuestring | string[]-Controlled value. String for single mode, string[] for multiple.
onValueChange(value: string | string[]) => void-Called with the new value when selection changes.
size"sm" | "md" | "lg""md"Controls height and padding of all items.
disabledbooleanfalseDisables all items in the group.

Accessibility

ToggleGroup uses roving tabindex: only the active or last-focused item sits in the page's Tab order, so Tab moves focus into and out of the whole group in a single stop rather than stepping through every item.

KeyFunction
tabMoves focus to the group's active item, or out to the next tabbable element if focus is already inside the group.
shift+tabMoves focus out of the group to the previous tabbable element.
enterActivates the focused item.
spaceActivates the focused item.
right arrowMoves focus to the next item, wrapping from the last item to the first.
down arrowMoves focus to the next item, wrapping from the last item to the first.
left arrowMoves focus to the previous item, wrapping from the first item to the last.
up arrowMoves focus to the previous item, wrapping from the first item to the last.
homeMoves focus to the first enabled item.
endMoves focus to the last enabled item.