Unified UI

ToggleGroup

A single or multi-select group of toggle buttons built on Radix UI ToggleGroup with shared variant/size context and roving keyboard navigation.

Overview

The ToggleGroup component provides a group of toggle buttons with either single-select (radio-like) or multi-select (checkbox-like) behavior. Built on Radix UI's ToggleGroup primitive, it shares variant and size context with its items and supports roving tabindex keyboard navigation.


Installation

Install the component via the CLI in one command.

npx @work-rjkashyap/unified-ui add toggle-group
pnpm dlx @work-rjkashyap/unified-ui add toggle-group
npx @work-rjkashyap/unified-ui add toggle-group
bunx @work-rjkashyap/unified-ui add toggle-group

If you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.

Or install the full package

Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.

npm install @work-rjkashyap/unified-ui
pnpm add @work-rjkashyap/unified-ui
yarn add @work-rjkashyap/unified-ui
bun add @work-rjkashyap/unified-ui

Anatomy

import {
	ToggleGroup,
	ToggleGroupItem,
} from "@work-rjkashyap/unified-ui";

Examples

Single Select

Multiple Select

Variants

Default
Outline
Ghost

Sizes

Small
Medium (default)
Large
SizeHeightPaddingFont Size
sm32px8px12px
md36px12px14px
lg40px16px14px

With Text Labels

Vertical Orientation

Disabled

Entire group disabled
Single item disabled

Props

ToggleGroup

PropTypeDefaultDescription
type"single" | "multiple"Required. Selection mode.
valuestring | string[]Controlled value (string for single, array for multi).
defaultValuestring | string[]Default value for uncontrolled usage.
onValueChange(value: string | string[]) => voidCallback fired when the active item(s) change.
variant"default" | "outline" | "ghost""default"Visual variant applied to all items.
size"sm" | "md" | "lg""md"Size applied to all items.
orientation"horizontal" | "vertical""horizontal"Layout orientation of the group.
disabledbooleanfalseDisables the entire group.
classNamestringAdditional CSS classes.

ToggleGroupItem

PropTypeDefaultDescription
valuestringRequired. Unique value for this item.
variant"default" | "outline" | "ghost"inheritedOverride the group-level variant for this item.
size"sm" | "md" | "lg"inheritedOverride the group-level size for this item.
disabledbooleanfalseDisables this specific item.
classNamestringAdditional CSS classes.

Accessibility

Icon-only toggle items must include an aria-label to be accessible to screen readers.

  • Roving tabindex — Arrow keys move focus between items. Tab moves focus out of the group. Managed by Radix UI.
  • aria-pressed — Radix automatically sets aria-pressed on each item based on selection state.
  • role="group" — Radix applies the correct group role on the root element.
  • Keyboard — Space or Enter toggles the focused item.
  • Disabled — Group-level disabled propagates to all items. Individual items can also be disabled.
  • Focus ring — Visible on keyboard navigation via focus-visible.

Design Tokens

TokenUsage
--secondaryActive item background
--foregroundActive item text color
--mutedHover background
--muted-foregroundInactive item text color
--borderOutline variant border color
--border-strongActive outline border / focus indicator
--duration-fastTransition speed
--easing-standardEasing curve for transitions

On this page