Skip to main content

Content Switcher

Toggle between two or more different views or content sections within the same context, typically presented as segmented buttons or tabs.

Preview​

Single Option States​

import { ContentSwitcher, ContentSwitcherOption } from "@/components/ui/content-switcher"

<ContentSwitcher type="single" defaultValue="1">
<ContentSwitcherOption value="1">Option 1</ContentSwitcherOption>
<ContentSwitcherOption value="2">Option 2</ContentSwitcherOption>
<ContentSwitcherOption value="3">Option 3</ContentSwitcherOption>
<ContentSwitcherOption value="4">Option 4</ContentSwitcherOption>
</ContentSwitcher>

API Reference​

PropTypeDefaultDescription
type"single" | "multiple"—Whether one or multiple options can be active at once
defaultValuestring—The value of the option to activate by default
valuestring—Controlled active value
onValueChangefunction—Callback when the active option changes

ContentSwitcherOption​

PropTypeDefaultDescription
valuestring—A unique value for the option
disabledbooleanfalseWhether the option is disabled

Accessibility​

  • Uses role="group" with proper toggle semantics via Radix ToggleGroup
  • Supports keyboard navigation (Arrow keys to move between options, Enter/Space to select)
  • Includes aria-pressed state for each option
  • Focus management follows WAI-ARIA roving tabindex pattern