0

Toggle Group

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

import { IconBold, IconItalic, IconUnderline } from "@tabler/icons-react"

import {

Installation

bunx --bun shadcn@latest add @ondo-ui/toggle-group

Usage

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

Composition

Use the following composition to build a ToggleGroup:

ToggleGroup
├── ToggleGroupItem
└── ToggleGroupItem

Examples

Outline

Use variant="outline" for an outline style.

import {
  ToggleGroup,
  ToggleGroupItem,

Size

Use the size prop to change the size of the toggle group.

import {
  ToggleGroup,
  ToggleGroupItem,

Spacing

Use spacing to add spacing between toggle group items.

import {
  ToggleGroup,
  ToggleGroupItem,

Vertical

Use orientation="vertical" for vertical toggle groups.

import { IconBold, IconItalic, IconUnderline } from "@tabler/icons-react"

import {

Disabled

import { IconBold, IconItalic, IconUnderline } from "@tabler/icons-react"

import {

Custom

A custom toggle group example.

Use font-normal to set the font weight.

"use client"

import * as React from "react"

API reference

The component wraps Base UI Toggle Group and accepts all of its props.