{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toggle-group-view-mode",
  "title": "Toggle Group View Mode",
  "description": "The Grid, List, Board view switcher: a labelled single-choice group that can never be empty, with icon buttons that have text names and an announced change.",
  "registryDependencies": [
    "toggle-group"
  ],
  "files": [
    {
      "path": "registry/patterns/toggle-group-view-mode/toggle-group-view-mode.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { KanbanIcon, LayoutGridIcon, ListIcon } from \"lucide-react\"\n\nimport { ToggleGroup, ToggleGroupItem } from \"@/components/ui/toggle-group\"\n\nexport type ViewMode = \"grid\" | \"list\" | \"board\"\n\nexport interface ToggleGroupViewModeProps {\n  value: ViewMode\n  onValueChange: (value: ViewMode) => void\n  modes?: ViewMode[]\n}\n\nconst META: Record<ViewMode, { label: string; Icon: typeof ListIcon }> = {\n  grid: { label: \"Grid\", Icon: LayoutGridIcon },\n  list: { label: \"List\", Icon: ListIcon },\n  board: { label: \"Board\", Icon: KanbanIcon },\n}\n\n/**\n * The view switcher above a collection: Grid, List, Board. It is a single-choice\n * group (one is always chosen, pressing the chosen one again does nothing), each\n * button has an icon and a hidden text name, and the change is announced\n * (\"Showing as list\"). The group is labelled \"View as\".\n */\nexport function ToggleGroupViewMode({\n  value,\n  onValueChange,\n  modes = [\"grid\", \"list\", \"board\"],\n}: ToggleGroupViewModeProps) {\n  return (\n    <div className=\"flex items-center gap-3\">\n      <ToggleGroup\n        type=\"single\"\n        variant=\"outline\"\n        value={value}\n        aria-label=\"View as\"\n        onValueChange={(next) => next && onValueChange(next as ViewMode)}\n      >\n        {modes.map((mode) => {\n          const { label, Icon } = META[mode]\n          return (\n            <ToggleGroupItem key={mode} value={mode} aria-label={label}>\n              <Icon aria-hidden=\"true\" />\n            </ToggleGroupItem>\n          )\n        })}\n      </ToggleGroup>\n      <span role=\"status\" className=\"sr-only\">\n        Showing as {value}\n      </span>\n    </div>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}