{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "command-palette-1",
  "title": "Command Dialog With Shortcuts",
  "description": "Command palette dialog opened from a Ctrl+K trigger button, listing grouped navigation and action commands with keyboard shortcut hints.",
  "dependencies": [
    "@base-ui/react"
  ],
  "registryDependencies": [
    "button",
    "command",
    "dialog",
    "kbd"
  ],
  "files": [
    {
      "path": "registry/blocks/command-palette/1/command-palette-block.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n  Command,\n  CommandEmpty,\n  CommandGroup,\n  CommandInput,\n  CommandItem,\n  CommandList,\n  CommandSeparator,\n  CommandShortcut,\n} from \"@/components/ui/command\"\nimport {\n  Dialog,\n  DialogContent,\n  DialogDescription,\n  DialogTitle,\n  DialogTrigger,\n} from \"@/components/ui/dialog\"\nimport { Kbd, KbdGroup } from \"@/components/ui/kbd\"\nimport { IconPlaceholder } from \"@/components/icons/icon-placeholder\"\n\ntype IconProps = { className?: string; size?: number | string }\n\nconst COMMAND_GROUP_CLASS =\n  \"p-1.5 **:[[cmdk-group-heading]]:px-3 **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:tracking-wide\"\nconst COMMAND_ITEM_CLASS = \"gap-2.5 px-3 py-2.5 text-sm\"\n\nconst navigationCommands = [\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"LayoutGrid\"\n        tabler=\"IconLayoutGrid\"\n        hugeicons=\"LayoutGridIcon\"\n        phosphor=\"GridFour\"\n        remixicon=\"RiLayoutGridLine\"\n        {...p}\n      />\n    ),\n    label: \"Go To Dashboard\",\n    shortcut: [\"G\", \"D\"],\n  },\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"FileText\"\n        tabler=\"IconFileText\"\n        hugeicons=\"File01Icon\"\n        phosphor=\"FileText\"\n        remixicon=\"RiFileTextLine\"\n        {...p}\n      />\n    ),\n    label: \"Open Projects\",\n    shortcut: [\"G\", \"P\"],\n  },\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"BarChart\"\n        tabler=\"IconChartBar\"\n        hugeicons=\"BarChartIcon\"\n        phosphor=\"ChartBar\"\n        remixicon=\"RiBarChartLine\"\n        {...p}\n      />\n    ),\n    label: \"View Analytics\",\n    shortcut: [\"G\", \"A\"],\n  },\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"Users\"\n        tabler=\"IconUsersGroup\"\n        hugeicons=\"UserGroupIcon\"\n        phosphor=\"UsersThree\"\n        remixicon=\"RiTeamLine\"\n        {...p}\n      />\n    ),\n    label: \"Browse Members\",\n    shortcut: [\"G\", \"M\"],\n  },\n]\n\nconst actionCommands = [\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"User\"\n        tabler=\"IconUser\"\n        hugeicons=\"UserIcon\"\n        phosphor=\"User\"\n        remixicon=\"RiUserLine\"\n        {...p}\n      />\n    ),\n    label: \"Edit Profile\",\n    shortcut: [\"Ctrl\", \"E\"],\n  },\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"Settings\"\n        tabler=\"IconSettings\"\n        hugeicons=\"SettingsIcon\"\n        phosphor=\"GearSix\"\n        remixicon=\"RiSettings3Line\"\n        {...p}\n      />\n    ),\n    label: \"Open Settings\",\n    shortcut: [\"Ctrl\", \",\"],\n  },\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"SquareTerminal\"\n        tabler=\"IconTerminal2\"\n        hugeicons=\"ComputerTerminal01Icon\"\n        phosphor=\"TerminalWindow\"\n        remixicon=\"RiTerminalBoxLine\"\n        {...p}\n      />\n    ),\n    label: \"Open Terminal\",\n    shortcut: [\"Ctrl\", \"`\"],\n  },\n]\n\nexport default function CommandPaletteBlock() {\n  const [open, setOpen] = React.useState(true)\n  const [ranLabel, setRanLabel] = React.useState<string | null>(null)\n\n  React.useEffect(() => {\n    function onKeyDown(event: KeyboardEvent) {\n      if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === \"k\") {\n        event.preventDefault()\n        setOpen((prev) => !prev)\n      }\n    }\n    window.addEventListener(\"keydown\", onKeyDown)\n    return () => window.removeEventListener(\"keydown\", onKeyDown)\n  }, [])\n\n  function run(label: string) {\n    setRanLabel(label)\n    setOpen(false)\n  }\n\n  return (\n    <section className=\"flex min-h-svh w-full flex-col items-center justify-center gap-3 bg-background px-6 py-12 text-foreground\">\n      <Dialog open={open} onOpenChange={setOpen}>\n        <DialogTrigger\n          render={\n            <Button\n              variant=\"outline\"\n              className=\"w-full max-w-md justify-start gap-2 text-muted-foreground\"\n            />\n          }\n        >\n          <IconPlaceholder\n            lucide=\"Search\"\n            tabler=\"IconSearch\"\n            hugeicons=\"SearchIcon\"\n            phosphor=\"MagnifyingGlass\"\n            remixicon=\"RiSearchLine\"\n            className=\"size-4 shrink-0\"\n            aria-hidden=\"true\"\n          />\n          <span className=\"flex-1 text-left\">Search…</span>\n          <KbdGroup>\n            <Kbd>Ctrl</Kbd>\n            <Kbd>K</Kbd>\n          </KbdGroup>\n        </DialogTrigger>\n\n        <DialogContent className=\"overflow-hidden p-0\" showCloseButton={false}>\n          <DialogTitle className=\"sr-only\">Command palette</DialogTitle>\n          <DialogDescription className=\"sr-only\">\n            Search for a command to run.\n          </DialogDescription>\n          <Command>\n            <CommandInput\n              aria-label=\"Search commands\"\n              placeholder=\"Search commands…\"\n              className=\"text-sm\"\n            />\n            <CommandList>\n              <CommandEmpty className=\"text-sm\">\n                No commands found.\n              </CommandEmpty>\n              <CommandGroup\n                heading=\"Navigation\"\n                className={COMMAND_GROUP_CLASS}\n              >\n                {navigationCommands.map((cmd) => (\n                  <CommandItem\n                    key={cmd.label}\n                    value={cmd.label}\n                    onSelect={() => run(cmd.label)}\n                    className={COMMAND_ITEM_CLASS}\n                  >\n                    <cmd.icon aria-hidden=\"true\" />\n                    <span className=\"flex-1 truncate\">{cmd.label}</span>\n                    <CommandShortcut>\n                      <KbdGroup>\n                        {cmd.shortcut.map((key) => (\n                          <Kbd key={key}>{key}</Kbd>\n                        ))}\n                      </KbdGroup>\n                    </CommandShortcut>\n                  </CommandItem>\n                ))}\n              </CommandGroup>\n              <CommandSeparator />\n              <CommandGroup heading=\"Actions\" className={COMMAND_GROUP_CLASS}>\n                {actionCommands.map((cmd) => (\n                  <CommandItem\n                    key={cmd.label}\n                    value={cmd.label}\n                    onSelect={() => run(cmd.label)}\n                    className={COMMAND_ITEM_CLASS}\n                  >\n                    <cmd.icon aria-hidden=\"true\" />\n                    <span className=\"flex-1 truncate\">{cmd.label}</span>\n                    <CommandShortcut>\n                      <KbdGroup>\n                        {cmd.shortcut.map((key) => (\n                          <Kbd key={key}>{key}</Kbd>\n                        ))}\n                      </KbdGroup>\n                    </CommandShortcut>\n                  </CommandItem>\n                ))}\n              </CommandGroup>\n            </CommandList>\n          </Command>\n        </DialogContent>\n      </Dialog>\n      {ranLabel ? (\n        <p className=\"text-xs text-muted-foreground\">\n          Last action:{\" \"}\n          <span className=\"font-medium text-foreground\">{ranLabel}</span>\n        </p>\n      ) : null}\n    </section>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/blocks/command-palette-1.tsx"
    }
  ],
  "meta": {
    "height": "630px",
    "tier": "free"
  },
  "docs": "Requires a `base-*` style in components.json (the `shadcn init` default). Legacy `new-york`/`radix-*` styles install Radix primitives, which reject the `render` prop this block uses.",
  "categories": [
    "command-palette"
  ],
  "type": "registry:block"
}