Skip to content
SevenOne

Search documentation

Search pages and components

Toggle Group

A set of toggles that work together, with single or multiple choice. Items are 52px wide and 44px tall.

Installation

npx shadcn@latest add @sevenone/toggle-group

Usage

import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

Examples

Multiple

<ToggleGroup type="multiple" defaultValue={["bold"]} aria-label="Text formatting">
  <ToggleGroupItem value="bold" aria-label="Bold"><Bold /></ToggleGroupItem>
  <ToggleGroupItem value="italic" aria-label="Italic"><Italic /></ToggleGroupItem>
  <ToggleGroupItem value="underline" aria-label="Underline"><Underline /></ToggleGroupItem>
</ToggleGroup>

Outline

<ToggleGroup type="single" variant="outline" defaultValue="bold" aria-label="Text style">
  …
</ToggleGroup>

Spacing

spacing adds a gap between items (in 4px steps), so each one keeps its own rounded corners.

<ToggleGroup type="single" variant="outline" spacing={2} defaultValue="day" aria-label="Period">
  <ToggleGroupItem value="day">Day</ToggleGroupItem>
  <ToggleGroupItem value="week">Week</ToggleGroupItem>
  <ToggleGroupItem value="month">Month</ToggleGroupItem>
</ToggleGroup>

Accessibility

  • Give the group a name with aria-label.
  • Arrow keys move between items; Space or Enter turns the focused item on or off.
  • Icon-only items need their own aria-label.