Toggle Group

PreviousNext

A group of toggle buttons that can be used for single or multiple selection.

Component toggle-group-demo not found in registry.

Usage

import { Bold, Italic, Underline } from "lucide-react"
 
import * as ToggleGroup from "@/registry/radix-ui/ui/toggle-group"
 
export function ToggleGroupExample() {
  const [format, setFormat] = React.useState("bold")
 
  return (
    <ToggleGroup.Root
      type="single"
      value={format}
      onValueChange={(value) => value && setFormat(value)}
      variant="primary"
      appearance="outline"
    >
      <ToggleGroup.Item value="bold">
        <Bold className="size-4" />
        Bold
      </ToggleGroup.Item>
      <ToggleGroup.Item value="italic">
        <Italic className="size-4" />
        Italic
      </ToggleGroup.Item>
      <ToggleGroup.Item value="underline">
        <Underline className="size-4" />
        Underline
      </ToggleGroup.Item>
    </ToggleGroup.Root>
  )
}

Examples

Basic Toggle Group

Component toggle-group-demo not found in registry.

Ghost Appearance

Component toggle-group-ghost not found in registry.

Different Sizes

Component toggle-group-sizes not found in registry.

Props

ToggleGroup.Root

This component is based on the Radix UI Toggle Group primitive.

Prop

Type

Default

type
single
multiple
-
value
string
-
defaultValue
string
-
onValueChange
(value: string) => void
-
appearance
outline
ghost
outline
size
xs
sm
md
lg
md
disabled
boolean
-
rovingFocus
boolean
true
orientation
horizontal
vertical
horizontal
className
string
-
children
ReactNode
-

ToggleGroup.Item

Prop

Type

Default

value
string
-
disabled
boolean
-
asChild
boolean
false
className
string
-
children
ReactNode
-