structyl

Toggle Group

stable

A set of two-state buttons that can be single or multiple select.

Basic usage

Examples

Single selection (alignment)

Use type="single" for mutually exclusive choices like text alignment.

Alignment: left

Single and multiple groups

Use type="single" for mutually exclusive choices and type="multiple" for toolbars.

Features

  • Single or multiple selection.
  • Roving focus navigation.

Installation

bash
pnpm dlx structyl add toggle-group

API Reference

ToggleGroup.Root

A group of toggles.

PropTypeDefault
type'single' | 'multiple'

Selection mode.

valuestring | string[]

Controlled value.

onValueChange(value) => void

Called when selection changes.

disabledboolean

Disable the whole group.

ToggleGroup.Item

A single toggle.

PropTypeDefault
valuestring

The item value.

disabledboolean

Disable the item.

Toggle Group | structyl