Toggle Group

Toggle group on Base UI that wraps Toggle buttons for single or multiple selection with shared keyboard navigation. Use it for text formatting or view modes.

src/registry/ui/toggle-group.tsx/r/toggle-group.json

Installation#

bash
npx shadcn@latest add @minidev/toggle-group

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/toggle-group.json

Usage#

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

export function Example() {
  return (
    <ToggleGroup multiple>
      <Toggle value="bold" aria-label="Bold" size="sm"><BoldIcon className="size-4" /></Toggle>
      <Toggle value="italic" aria-label="Italic" size="sm"><ItalicIcon className="size-4" /></Toggle>
      <Toggle value="underline" aria-label="Underline" size="sm"><UnderlineIcon className="size-4" /></Toggle>
    </ToggleGroup>
  )
}

API reference#

Also accepts every prop of ToggleGroupPrimitive props, passed through to the root element.

Dependencies#

npm

@base-ui/react

Built from

No other MiniDev files

Examples#

All button components

Learn more