Toggle Group

Turns formatting or view options on and off.

@paneui/theme@base-ui/reactclass-variance-authority

Installation

pnpm dlx shadcn@latest add @paneui/toggle-group

Usage

Composition

Examples

Outline

Single Toggle

Sizes

RTL

One value or many

The value is always an array. Without multiple it holds at most one item, so read value[0]; to stop the user clearing the choice, ignore empty arrays in onValueChange.

When to use something else

For a one-of-few value with a raised thumb (billing cycle, view mode) use SegmentedControl. Inside a Toolbar, use ToolbarToggle so the item joins the toolbar's arrow-key loop.

API Reference

Built on the Toggle Group primitive. Only the props this library adds or changes are listed; everything else passes through.

ToggleGroup

Also accepts every prop of ToggleGroup.

variant= "default"
"default" | "outline"
default fills only the pressed item; outline frames every item, for settings panels.
size= "default"
"xs" | "sm" | "default" | "lg"
Height 24 / 28 / 32 / 36px, matching the button sizes.
PropTypeDefaultDescription
variant"default" | "outline""default"default fills only the pressed item; outline frames every item, for settings panels.
size"xs" | "sm" | "default" | "lg""default"Height 24 / 28 / 32 / 36px, matching the button sizes.
data-variant
The group variant.
data-size
The group size.
Data attributeDescription
data-variantThe group variant.
data-sizeThe group size.

ToggleGroupItem

Takes variant / size from the group unless set. Also accepts every prop of Toggle.

value*
string
The item's value in the group.
PropTypeDefaultDescription
value*string—The item's value in the group.
data-pressed
Present when pressed.
data-variant
The resolved variant.
data-size
The resolved size.
Data attributeDescription
data-pressedPresent when pressed.
data-variantThe resolved variant.
data-sizeThe resolved size.

Toggle

Also accepts every prop of Toggle.

variant= "default"
"default" | "outline"
default fills only the pressed item; outline frames every item, for settings panels.
size= "default"
"xs" | "sm" | "default" | "lg"
Height 24 / 28 / 32 / 36px, matching the button sizes.
PropTypeDefaultDescription
variant"default" | "outline""default"default fills only the pressed item; outline frames every item, for settings panels.
size"xs" | "sm" | "default" | "lg""default"Height 24 / 28 / 32 / 36px, matching the button sizes.