Component

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.

View component changelog
preview
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} /> ))} </ToggleGroup.Root> </div>; }; export default ToggleGroupExampleBasic;

Root component for the ToggleGroup component.

PropTypeDefault
type
enum
single
multiple
boolean
false
variant
string
--
size
string
--
className
string
''
loop
boolean
true
orientation
enum
horizontal
value
string[]
--
defaultValue
string[]
[]
onValueChange
(value: string[]) => void
--
color
string
null
customRootClass
string
''
disabled
boolean
false
dir
enum
ltr
rovingFocus
boolean
true
asChild
boolean
false
children
React.ReactNode
null

Item component for the ToggleGroup component.

PropTypeDefault
children
React.ReactNode
null
value
any
null
iconOnly
boolean
false
className
string
''
disabled
boolean
false
asChild
boolean
false
ShortcutDescription
Tab

Moves focus into or out of the toggle group.

ArrowRight

Moves focus to the next enabled item when orientation is horizontal.

ArrowDown

Moves focus to the next enabled item when orientation is vertical.

ArrowLeft

Moves focus to the previous enabled item when orientation is horizontal.

ArrowUp

Moves focus to the previous enabled item when orientation is vertical.

Home

Moves focus to the first enabled item.

End

Moves focus to the last enabled item.

Space

Toggles the focused item.

Enter

Toggles the focused item.

ReferenceWhat Rad UI follows

Each item follows toggle button semantics with aria-pressed for the selected state.