ToggleGroup is a component that allows you to group multiple toggles together. Useful for when you want to allow users to select multiple options. For example, a user can select multiple filters for a search.

React
'use client'; import React from 'react'; import ToggleGroup from '@radui/ui/ToggleGroup'; import { Columns3, Crop, Layers3, Square } from 'lucide-react'; // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args const items = [ { label: <Square size={15} strokeWidth={2} />, value: 'item1' }, { label: <Crop size={15} strokeWidth={2} />, value: 'item2' }, { label: <Layers3 size={15} strokeWidth={2} />, value: 'item3' }, { label: <Columns3 size={15} strokeWidth={2} />, value: 'item4' } ]; const ToggleGroupExampleBasic = () => { return <div> <ToggleGroup.Root type="multiple" defaultValue={['item1']}> {items.map((item) => ( <ToggleGroup.Item key={item.value} value={item.value} iconOnly aria-label={item.value}> {item.label} </ToggleGroup.Item> ))} </ToggleGroup.Root> </div>; }; export default ToggleGroupExampleBasic;

Root component for the ToggleGroup component.

PropTypeDefault

type

enum

single

className

string''

loop

boolean

true

orientation

enum

horizontal

value

any--

defaultValue

any[]

onValueChange

function--

color

stringnull

customRootClass

string''

disabled

boolean

false

dir

enum

ltr

rovingFocus

boolean

true

asChild

boolean

false

children

React.ReactNodenull

Item component for the ToggleGroup component.

PropTypeDefault

children

React.ReactNodenull

value

anynull

iconOnly

boolean

false

className

string''

disabled

boolean

false

asChild

boolean

false