Skip to Content
ComponentsToggleGroup

Toggle Group

A group of toggle buttons where one or multiple items can be pressed at a time. Built on Base UI’s Toggle and ToggleGroup primitives. In single-select mode, a sliding indicator animates between the active item using Motion (with CSS transition fallback).

Import

import { ToggleGroup } from "chunks-ui";

Basic Usage

By default, the toggle group operates in single-select mode. Only one item can be pressed at a time, and a sliding indicator highlights the active selection:

<ToggleGroup.Root defaultValue={["bold"]}> <ToggleGroup.Item value="bold">Bold</ToggleGroup.Item> <ToggleGroup.Item value="italic">Italic</ToggleGroup.Item> <ToggleGroup.Item value="underline">Underline</ToggleGroup.Item> </ToggleGroup.Root>

Multiple Selection

Set multiple to allow pressing more than one item at a time. Each pressed item gets its own background highlight instead of a shared sliding indicator:

<ToggleGroup.Root multiple defaultValue={["bold", "italic"]}> <ToggleGroup.Item value="bold">Bold</ToggleGroup.Item> <ToggleGroup.Item value="italic">Italic</ToggleGroup.Item> <ToggleGroup.Item value="underline">Underline</ToggleGroup.Item> </ToggleGroup.Root>

Controlled

function ControlledToggleGroup() { const [value, setValue] = useState(["bold"]); return ( <ToggleGroup.Root value={value} onValueChange={setValue}> <ToggleGroup.Item value="bold">Bold</ToggleGroup.Item> <ToggleGroup.Item value="italic">Italic</ToggleGroup.Item> <ToggleGroup.Item value="underline">Underline</ToggleGroup.Item> </ToggleGroup.Root> ); }

Compound Parts

PartDescription
ToggleGroup.RootContainer that manages selection state. Renders a pill-shaped muted background with inline-flex layout. In single-select mode, renders a sliding indicator behind the active item.
ToggleGroup.ItemIndividual toggle button. Shows muted text by default, foreground text when pressed. In multiple mode, each pressed item gets its own background highlight.

ToggleGroup.Root Props

PropTypeDefaultDescription
valueunknown[]Controlled pressed values
defaultValueunknown[][]Initial pressed values (uncontrolled)
onValueChange(value: unknown[]) => voidCalled when the pressed state changes
multiplebooleanfalseAllow multiple items to be pressed at once
orientation"horizontal" | "vertical""horizontal"Layout direction
disabledbooleanfalseDisable all toggle items
classNamestringAdditional CSS classes

ToggleGroup.Item Props

PropTypeDefaultDescription
valueunknownrequiredThe value this item represents
disabledbooleanfalseDisable this toggle item
classNamestringAdditional CSS classes
Last updated on