ToggleGroup

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

inputs
button
toggle
group
selection

Preview

Variants

Multi-selection toggle group.

Code

TSX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
import { Bold, Italic, Underline } from "lucide-react"

export function ToggleGroupDemo() {
  return (
    <ToggleGroup type="multiple">
      <ToggleGroupItem value="bold" aria-label="Toggle bold">
        <Bold className="h-4 w-4" />
      </ToggleGroupItem>
      <ToggleGroupItem value="italic" aria-label="Toggle italic">
        <Italic className="h-4 w-4" />
      </ToggleGroupItem>
      <ToggleGroupItem value="underline" aria-label="Toggle underline">
        <Underline className="h-4 w-4" />
      </ToggleGroupItem>
    </ToggleGroup>
  )
}

API Reference

PropTypeDefaultDescription
typesingle | multiple-Whether a single or multiple items can be selected.
valuestring | string[]-The controlled value of the item(s) to select.
defaultValuestring | string[]-The value of the item(s) to select by default.
onValueChangefunction-Event handler called when the value changes.
variantdefault | outlinedefaultThe visual style of the toggle group.
sizesm | default | lgdefaultThe size of the toggle group items.