Redpanda UIRedpanda UI

Toggle Group

A set of two-state buttons that can be toggled on or off.

Made by imskyleen

Installation

Loading component...

When to use

Toggle Group operates as a segmented control, allowing users to filter or adjust the display of content within the current view. Unlike tabs that navigate between distinct content areas, segmented controls modify how existing content is presented. Content is typically shared across different segments, with the control determining what's visible or how it's formatted.

Use Toggle Group when:

  • Filtering or adjusting a single content view
  • Toggling between different presentations of the same data
  • Content is shared across segments (list vs. grid, day vs. week vs. month)
  • Making formatting choices (bold, italic, underline)
  • The view context remains the same, just filtered or adjusted

Don't use Toggle Group when:

  • Navigating between completely different content areas (use Tabs instead)
  • Each option shows unique, non-overlapping content
  • The interaction triggers a full content change rather than a filter/adjustment

Usage

<ToggleGroup>
  <ToggleGroupItem>A</ToggleGroupItem>
  <ToggleGroupItem>B</ToggleGroupItem>
  <ToggleGroupItem>C</ToggleGroupItem>
</ToggleGroup>

Examples

Multiple

Loading component...

Outline Variant

The outline variant provides a bordered container around the toggle group, ideal for segmented controls that filter or adjust content.

Loading component...

Attached Mode

Loading component...

Vertical Orientation

Loading component...

Combined with Tabs

This example demonstrates the key difference between tabs (navigation) and toggle groups (filtering). Tabs navigate between different content areas, while toggle groups filter or adjust content within each tab's view.

Loading component...

Props

Animate UI Props

ToggleGroup

Prop

Type

ToggleGroupItem

Prop

Type

Keyboard interactions

KeyAction
Tab into the groupFocus lands on the currently-pressed item, or the first item if none.
ArrowLeft / ArrowRightMoves between items (horizontal).
ArrowUp / ArrowDownMoves between items (vertical).
Space / EnterToggles the focused item.
Home / EndJumps to first / last item.

Accessibility

  • The container carries role="group" (or role="radiogroup" for type="single"), and each item is an aria-pressed button.
  • Focus is roving — only one item is tabbable at a time. Arrow keys move both focus and (for type="single") selection.
  • Provide an accessible group label — either aria-label on ToggleGroup or a visible heading with aria-labelledby — otherwise the purpose of the group isn't announced.
  • Use type="single" for mutually-exclusive filters (like/dislike, sort direction) and type="multiple" for independent switches (text formatting, feature flags).

Credits

Recent changes

  • patchv1.2.0Pin shipped dependency floors to the version we develop against. Registry items now declare ranges like `^5.1.9` (the actual installed version) instead of collapsing to `^5.0.0`, so consumers start on the known-tested b…#133
  • minorv1.1.0Theme docs refresh, readability pass on semantic foregrounds, and consumer-facing Base UI regression fixes.#121
  • minorv1.0.0Post-Base-UI polish. Public API unchanged.#116
  • majorv1.0.0Migrate every Radix-based primitive to `@base-ui/react@^1.4.0` (Base UI).#114
  • minorv0.3.0Add theme-provider component to the registry with documentation and tests. Includes playground type improvements (export RegistryItem, remove as-const boilerplate) and docs site dark mode border color fix.#109
See full history →
Built by malinskibeniamin. The source code is available on GitHub.

On this page