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/bearnie/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

Prop Type Default Description
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
defaultValue string | string[] - Default pressed value(s)
disabled boolean false Disables all items in the group
class string - Additional CSS classes

ToggleGroupItem

Prop Type Default Description
value string - Unique value for the item (required)
disabled boolean false Disables the toggle item
class string - Additional CSS classes