Ballmac UI home

Toggle Group

A compact roving-focus selection group for one or several pressed options, with clear states and mobile-friendly sizing.

Project view

Pick your preferred layout

Projects shown as cards

Installation

$ pnpm dlx shadcn@latest add @ballmac/toggle-group

Usage

import { ToggleGroup, ToggleGroupItem } from "@/components/ballmac/toggle-group"

The full example is in the Code tab above.

Examples

Multiple filters

API reference

PropTypeDefault
variant

Surface treatment shared by the items.

"default" | "outline""default"
size

Item height.

"sm" | "default" | "lg""default"

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
TabEnters or exits the group
Arrow keysMoves focus between items
Enter / SpaceSelects the focused item

Use with AI

Lets users choose one or multiple options from a short row while Radix handles roving focus. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Toggle Group (@ballmac/toggle-group) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • View mode or density selector
  • Formatting options that can coexist

Not for

  • Unrelated actions; use button-group
  • A long list of options; use select

Registry JSON: https://ui.ballmac.com/r/toggle-group.json

Credits

Free to use in personal and commercial projects.