127+ Primitives

Permission Switch

Inputs

Tactile segmented control where the selected option expands to reveal its label while others collapse to icon-only, with a sliding pill and blur transitions.

Segmented ControlAdaptive WidthA11y RadiogroupActive Motion
/r/permission-switch.json
Selected State: allow

Installation

Install directly into your project using the shadcn CLI or copy the source code manually.

Requires:framer-motionlucide-reactclsxtailwind-merge
$npx shadcn@latest add "https://boseui.site/r/permission-switch.json"

Props

TypeScript props supported by <PermissionSwitch />.

8 props
PropTypeDefaultDescription
optionsPermissionOption[]DEFAULT_PERMISSION_OPTIONSArray of selectable option items with value, label, and optional icon component.
valuestringundefinedControlled active option value.
defaultValuestring"allow"Initial uncontrolled active option value.
onChange(value: string) => voidundefinedCallback triggered when the user selects a different option.
activeMotionbooleanfalseIf true, expands the active tab with a slower, cinematic expansion curve on selection.
slowDurationnumber780Transition duration in milliseconds when activeMotion is enabled.
durationnumber460Standard transition duration in milliseconds when activeMotion is false.
aria-labelstring"Permission"Accessible ARIA label describing the radiogroup purpose.

Key Features

  • Dynamically measures label dimensions on render to smoothly animate container width and pill translation.
  • Active tab expands gracefully with blur and opacity crossfades while inactive tabs collapse to icons.
  • Optional activeMotion prop enables a luxurious, slow-motion elastic expansion on selection change.
  • Strictly prop-driven: pass custom labels, values, and Lucide icons directly through props.

Keyboard & Accessibility

  • Full WAI-ARIA radiogroup pattern with arrow key (ArrowLeft, ArrowRight, ArrowUp, ArrowDown), Home, and End navigation.
  • Automatic tabIndex management focusing active option and maintaining clean keyboard focus outline rings.
  • Respects prefers-reduced-motion by bypassing transition durations and updating layout instantly.