{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "command-menu-01",
  "description": "A command palette to jump to a page or run an action, with shortcuts shown beside each action.",
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/command-menu.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/command-menu/command-menu-01.tsx",
      "content": "'use client'\n\nimport {\n  CommandMenu,\n  type CommandMenuGroup,\n  CommandMenuTrigger,\n  useCommandMenuShortcut,\n} from '@/registry/components/dashboardblocks/command-menu'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { type ReactNode, useCallback, useState } from 'react'\n\ninterface CommandMenu1Props {\n  /** Opens the menu with ⌘ or Ctrl and this key. */\n  shortcutKey?: string\n  onAction?: (id: string) => void\n  onNavigate?: (href: string) => void\n}\n\nconst exampleProps: CommandMenu1Props = { shortcutKey: '/' }\n\nconst pages: CommandMenuGroup = {\n  heading: 'Pages',\n  items: [\n    {\n      href: '/',\n      icon: (\n        <IconPlaceholder\n          lucide='LayoutDashboardIcon'\n          tabler='IconDashboard'\n          hugeicons='DashboardSquare01Icon'\n          phosphor='SquaresFourIcon'\n          remixicon='RiDashboardLine'\n        />\n      ),\n      id: 'page-overview',\n      keywords: ['home', 'dashboard'],\n      label: 'Overview',\n    },\n    {\n      href: '/orders',\n      icon: (\n        <IconPlaceholder\n          lucide='ShoppingCartIcon'\n          tabler='IconShoppingCart'\n          hugeicons='ShoppingCart01Icon'\n          phosphor='ShoppingCartIcon'\n          remixicon='RiShoppingCartLine'\n        />\n      ),\n      id: 'page-orders',\n      keywords: ['sales', 'purchases'],\n      label: 'Orders',\n    },\n    {\n      href: '/customers',\n      icon: (\n        <IconPlaceholder\n          lucide='UsersIcon'\n          tabler='IconUsers'\n          hugeicons='UserGroupIcon'\n          phosphor='UsersIcon'\n          remixicon='RiTeamLine'\n        />\n      ),\n      id: 'page-customers',\n      keywords: ['people', 'contacts'],\n      label: 'Customers',\n    },\n    {\n      href: '/settings/billing',\n      icon: (\n        <IconPlaceholder\n          lucide='CreditCardIcon'\n          tabler='IconCreditCard'\n          hugeicons='CreditCardIcon'\n          phosphor='CreditCardIcon'\n          remixicon='RiBankCardLine'\n        />\n      ),\n      id: 'page-billing',\n      keywords: ['invoices', 'plan', 'payment'],\n      label: 'Billing',\n    },\n  ],\n}\n\nconst actions: { icon: ReactNode; id: string; label: string; shortcut?: string }[] = [\n  {\n    icon: (\n      <IconPlaceholder\n        lucide='PlusIcon'\n        tabler='IconPlus'\n        hugeicons='PlusSignIcon'\n        phosphor='PlusIcon'\n        remixicon='RiAddLine'\n      />\n    ),\n    id: 'new-order',\n    label: 'Create order',\n    shortcut: '⌘N',\n  },\n  {\n    icon: (\n      <IconPlaceholder\n        lucide='UserPlusIcon'\n        tabler='IconUserPlus'\n        hugeicons='UserAdd01Icon'\n        phosphor='UserPlusIcon'\n        remixicon='RiUserAddLine'\n      />\n    ),\n    id: 'invite',\n    label: 'Invite a teammate',\n  },\n  {\n    icon: (\n      <IconPlaceholder\n        lucide='DownloadIcon'\n        tabler='IconDownload'\n        hugeicons='Download01Icon'\n        phosphor='DownloadIcon'\n        remixicon='RiDownloadLine'\n      />\n    ),\n    id: 'export-customers',\n    label: 'Export customers',\n  },\n]\n\nconst CommandMenu1 = (props: CommandMenu1Props) => {\n  const [lastCommand, setLastCommand] = useState<string | null>(null)\n  const {\n    onAction = (id: string) =>\n      setLastCommand(actions.find((action) => action.id === id)?.label ?? id),\n    onNavigate = (href: string) => setLastCommand(`Go to ${href}`),\n    shortcutKey = 'k',\n  } = props\n  const [open, setOpen] = useState(false)\n  const openMenu = useCallback(() => setOpen(true), [])\n  useCommandMenuShortcut(openMenu, shortcutKey)\n\n  const groups: CommandMenuGroup[] = [\n    pages,\n    {\n      heading: 'Actions',\n      items: actions.map((action) => ({\n        ...action,\n        onSelect: () => onAction(action.id),\n      })),\n    },\n  ]\n\n  return (\n    <section className='@container flex flex-col items-center gap-3'>\n      <CommandMenuTrigger\n        onClick={openMenu}\n        placeholder='Search or run a command'\n        shortcut={`⌘${shortcutKey.toUpperCase()}`}\n      />\n      <p role='status' className='text-muted-foreground min-h-5 text-sm'>\n        {lastCommand && `Last command: ${lastCommand}.`}\n      </p>\n      <CommandMenu\n        open={open}\n        onOpenChange={setOpen}\n        groups={groups}\n        onNavigate={onNavigate}\n        placeholder='Search pages and actions'\n      />\n    </section>\n  )\n}\n\nexport { CommandMenu1, exampleProps as commandMenu1ExampleProps, type CommandMenu1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/command-menu/command-menu-01.tsx"
    }
  ],
  "meta": {
    "shows": "A command palette to jump to a page or run an action, with shortcuts shown beside each action.",
    "size": "half",
    "usedWith": [
      "app-shell-01",
      "command-menu-02"
    ],
    "component": "CommandMenu1",
    "props": "{ shortcutKey?: string; onAction?: (id: string) => void; onNavigate?: (href: string) => void }"
  },
  "type": "registry:component"
}
