Homelogologo
Sponsor

ToggleGroup

A set of two-state buttons that can be toggled on or off.

Usage

The ToggleGroup component allows users to select one or more options from a set of toggles.

import { ToggleGroup } from "@elemnts-ui/react"
<ToggleGroup.Root> <ToggleGroup.Item value="a">A</ToggleGroup.Item> <ToggleGroup.Item value="b">B</ToggleGroup.Item> </ToggleGroup.Root>

Attached

Use the attached prop to visually connect the toggle items together into a unified group.

Multiple

Allow multiple items to be selected by setting the multiple prop to true.

Orientation

The toggle group can be oriented horizontally or vertically.

Controlled

Use the value and onValueChange props to control the selected items.

Disabled

The entire toggle group or individual items can be disabled.

API Reference

ToggleGroup

Manages the state of the toggle group and provides context for the toggle items.

PropTypeDefault
valuestring
disabledbooleanfalse
asChildbooleanfalse
multiplebooleanfalse
onValueChange(value: string) => void

ToggleGroupItem

The toggle group item component.

PropTypeDefault
valuestring
disabledbooleanfalse
asChildbooleanfalse