bearnie

Toggle Group

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

Installation

npx bearnie add toggle-group
npx bearnie add toggle-group

Usage

import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle"
<ToggleGroup type="single">
<ToggleGroupItem value="a">A</ToggleGroupItem>
<ToggleGroupItem value="b">B</ToggleGroupItem>
<ToggleGroupItem value="c">C</ToggleGroupItem>
</ToggleGroup>

Examples

Outline

Multiple

Sizes

Vertical

Disabled

Anatomy

  • ToggleGroup - Container that manages toggle state
  • ToggleGroupItem - Individual toggle button within the group

Props

ToggleGroup

PropTypeDefaultDescription
type”single” | “multiple""single”Whether single or multiple items can be pressed
variant”default” | “outline""default”Visual style variant
size”sm” | “default” | “lg""default”Size of the toggle items
orientation”horizontal” | “vertical""horizontal”Layout orientation
defaultValuestring | string[]-Default pressed value(s)
disabledbooleanfalseDisables all items in the group
classstring-Additional CSS classes

ToggleGroupItem

PropTypeDefaultDescription
valuestring-Unique value for the item (required)
disabledbooleanfalseDisables the toggle item
classstring-Additional CSS classes