Skip to Content
Columbus

Toggle Group

A group of toggle buttons where one or multiple can be selected.

Installation

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

Usage

import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";

<ToggleGroup aria-label="Text style" defaultValue={["bold"]}>
  <ToggleGroupItem aria-label="Bold" value="bold">
    <BoldIcon />
  </ToggleGroupItem>
  <ToggleGroupItem aria-label="Italic" value="italic">
    <ItalicIcon />
  </ToggleGroupItem>
</ToggleGroup>;

Every ToggleGroupItem needs a value. The group's value is always an array, even when only one item can be pressed. Use the arrow keys to move between items.

Multiple selection

By default, pressing an item releases the others. Pass multiple to allow several at once.

Outline

variant="outline" joins the items into one bordered control. Add ToggleGroupSeparator between items for a divider.

Vertical

Set orientation="vertical" on the group, and orientation="horizontal" on each separator.

API reference

Also accepts every Base UI Toggle Group prop, like value, defaultValue, onValueChange, multiple, and disabled. ToggleGroupItem accepts every Toggle prop.

ToggleGroup

Prop

Type

ToggleGroupSeparator

Prop

Type

On this page