{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "command-palette-3",
  "title": "Cmd+K Searchable Palette",
  "description": "Command palette wired to a global Cmd+K listener, opening a searchable dialog of grouped commands with Kbd shortcuts and a last-action readout.",
  "dependencies": [
    "@base-ui/react"
  ],
  "registryDependencies": [
    "button",
    "command",
    "dialog",
    "kbd"
  ],
  "files": [
    {
      "path": "registry/blocks/command-palette/3/command-palette-block.tsx",
      "content": "\"use client\"\n\nimport { useEffect, useState } from \"react\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n  Command,\n  CommandDialog,\n  CommandEmpty,\n  CommandGroup,\n  CommandInput,\n  CommandItem,\n  CommandList,\n  CommandShortcut,\n} from \"@/components/ui/command\"\nimport { Kbd, KbdGroup } from \"@/components/ui/kbd\"\nimport { IconPlaceholder } from \"@/components/icons/icon-placeholder\"\n\ntype IconProps = { className?: string; size?: number | string }\n\ntype IconRenderer = (props: IconProps) => React.ReactNode\n\ntype PaletteCommand = {\n  id: string\n  label: string\n  group: string\n  icon: IconRenderer\n  shortcut: string[]\n}\n\nconst commands: PaletteCommand[] = [\n  {\n    id: \"dashboard\",\n    label: \"Go To Dashboard\",\n    group: \"Navigation\",\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    shortcut: [\"G\", \"D\"],\n  },\n  {\n    id: \"projects\",\n    label: \"Open Projects\",\n    group: \"Navigation\",\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    shortcut: [\"G\", \"P\"],\n  },\n  {\n    id: \"analytics\",\n    label: \"View Analytics\",\n    group: \"Navigation\",\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    shortcut: [\"G\", \"A\"],\n  },\n  {\n    id: \"members\",\n    label: \"Browse Members\",\n    group: \"Navigation\",\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    shortcut: [\"G\", \"M\"],\n  },\n  {\n    id: \"new-project\",\n    label: \"Create New Project\",\n    group: \"Actions\",\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"Plus\"\n        tabler=\"IconPlus\"\n        hugeicons=\"Add01Icon\"\n        phosphor=\"Plus\"\n        remixicon=\"RiAddLine\"\n        {...p}\n      />\n    ),\n    shortcut: [\"Ctrl\", \"N\"],\n  },\n  {\n    id: \"profile\",\n    label: \"Edit Profile\",\n    group: \"Actions\",\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    shortcut: [\"Ctrl\", \"E\"],\n  },\n  {\n    id: \"settings\",\n    label: \"Open Settings\",\n    group: \"Actions\",\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    shortcut: [\"Ctrl\", \",\"],\n  },\n  {\n    id: \"terminal\",\n    label: \"Open Terminal\",\n    group: \"Actions\",\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    shortcut: [\"Ctrl\", \"`\"],\n  },\n  {\n    id: \"theme\",\n    label: \"Toggle Dark Mode\",\n    group: \"Preferences\",\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"Moon\"\n        tabler=\"IconMoon\"\n        hugeicons=\"MoonIcon\"\n        phosphor=\"Moon\"\n        remixicon=\"RiMoonLine\"\n        {...p}\n      />\n    ),\n    shortcut: [\"Ctrl\", \"K\", \"T\"],\n  },\n]\n\nconst groupOrder = [\"Navigation\", \"Actions\", \"Preferences\"]\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\nexport default function CommandPaletteBlock() {\n  const [open, setOpen] = useState(false)\n  const [ranLabel, setRanLabel] = useState<string | null>(null)\n\n  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(cmd: PaletteCommand) {\n    setRanLabel(cmd.label)\n    setOpen(false)\n  }\n\n  return (\n    <section className=\"flex min-h-svh w-full flex-col items-center justify-center gap-6 bg-muted/30 px-6 py-16 text-foreground\">\n      <div className=\"flex w-full max-w-md flex-col items-center gap-4 text-center\">\n        <span className=\"text-xs font-semibold tracking-widest text-muted-foreground uppercase\">\n          Acme Console\n        </span>\n        <h2 className=\"font-heading text-2xl font-semibold tracking-tight\">\n          Jump to anything\n        </h2>\n        <p className=\"text-sm text-muted-foreground\">\n          Search projects, run actions, and navigate without leaving the\n          keyboard.\n        </p>\n        <Button\n          type=\"button\"\n          variant=\"outline\"\n          onClick={() => setOpen(true)}\n          className=\"w-full justify-between font-normal text-muted-foreground\"\n        >\n          <span className=\"flex items-center gap-2\">\n            <IconPlaceholder\n              lucide=\"Search\"\n              tabler=\"IconSearch\"\n              hugeicons=\"SearchIcon\"\n              phosphor=\"MagnifyingGlass\"\n              remixicon=\"RiSearchLine\"\n              data-icon=\"inline-start\"\n              className=\"size-4\"\n            />\n            Search commands…\n          </span>\n          <KbdGroup>\n            <Kbd>Ctrl</Kbd>\n            <Kbd>K</Kbd>\n          </KbdGroup>\n        </Button>\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      </div>\n\n      <CommandDialog open={open} onOpenChange={setOpen}>\n        <Command>\n          <CommandInput\n            aria-label=\"Type a command or search\"\n            placeholder=\"Type a command or search…\"\n            className=\"text-sm\"\n          />\n          <CommandList>\n            <CommandEmpty className=\"text-sm\">No results found.</CommandEmpty>\n            {groupOrder.map((group) => (\n              <CommandGroup\n                key={group}\n                heading={group}\n                className={COMMAND_GROUP_CLASS}\n              >\n                {commands\n                  .filter((cmd) => cmd.group === group)\n                  .map((cmd) => (\n                    <CommandItem\n                      key={cmd.id}\n                      value={cmd.label}\n                      onSelect={() => run(cmd)}\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            ))}\n          </CommandList>\n\n          <div className=\"flex items-center justify-between border-t border-border px-4 py-2.5 text-xs text-muted-foreground\">\n            <div className=\"flex items-center gap-3\">\n              <span className=\"flex items-center gap-1.5\">\n                <KbdGroup>\n                  <Kbd>↑</Kbd>\n                  <Kbd>↓</Kbd>\n                </KbdGroup>\n                Navigate\n              </span>\n              <span className=\"flex items-center gap-1.5\">\n                <Kbd>\n                  <IconPlaceholder\n                    lucide=\"CornerDownLeft\"\n                    tabler=\"IconCornerDownLeft\"\n                    hugeicons=\"CornerDownLeftIcon\"\n                    phosphor=\"ArrowElbowDownLeft\"\n                    remixicon=\"RiCornerDownLeftLine\"\n                    className=\"size-3\"\n                  />\n                </Kbd>\n                Select\n              </span>\n            </div>\n            <span className=\"hidden items-center gap-1.5 sm:flex\">\n              <span className=\"size-2 rounded-full bg-primary\" />\n              Acme\n            </span>\n          </div>\n        </Command>\n      </CommandDialog>\n    </section>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/blocks/command-palette-3.tsx"
    }
  ],
  "meta": {
    "height": "304px",
    "tier": "free"
  },
  "categories": [
    "command-palette"
  ],
  "type": "registry:block"
}