{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "command-palette-2",
  "title": "Palette With Recent Items",
  "description": "Command palette dialog with a Recent section of timestamped files and pages above categorized results, and a footer bar of keyboard hints.",
  "dependencies": [
    "@base-ui/react"
  ],
  "registryDependencies": [
    "badge",
    "button",
    "command",
    "dialog",
    "kbd"
  ],
  "files": [
    {
      "path": "registry/blocks/command-palette/2/command-palette-block.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Badge } from \"@/components/ui/badge\"\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 recentItems = [\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"File\"\n        tabler=\"IconFile\"\n        hugeicons=\"FileIcon\"\n        phosphor=\"File\"\n        remixicon=\"RiFileLine\"\n        {...p}\n      />\n    ),\n    label: \"Q3 Budget Review.xlsx\",\n    time: \"2 Min Ago\",\n  },\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"AppWindow\"\n        tabler=\"IconAppWindow\"\n        hugeicons=\"BrowserIcon\"\n        phosphor=\"Browser\"\n        remixicon=\"RiWindowLine\"\n        {...p}\n      />\n    ),\n    label: \"Acme Design System\",\n    time: \"1 Hour Ago\",\n  },\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"BookOpen\"\n        tabler=\"IconBook2\"\n        hugeicons=\"BookOpenIcon\"\n        phosphor=\"BookOpen\"\n        remixicon=\"RiBookOpenLine\"\n        {...p}\n      />\n    ),\n    label: \"Onboarding Docs\",\n    time: \"Yesterday\",\n  },\n]\n\nconst results = [\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"Folder\"\n        tabler=\"IconFolder\"\n        hugeicons=\"FolderIcon\"\n        phosphor=\"Folder\"\n        remixicon=\"RiFolderLine\"\n        {...p}\n      />\n    ),\n    label: \"Marketing Assets\",\n    category: \"Folder\",\n  },\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"FileBarChart\"\n        tabler=\"IconFileChart\"\n        hugeicons=\"ChartHistogramIcon\"\n        phosphor=\"FileText\"\n        remixicon=\"RiFileChartLine\"\n        {...p}\n      />\n    ),\n    label: \"Campaign Performance Report\",\n    category: \"File\",\n  },\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"Hash\"\n        tabler=\"IconHash\"\n        hugeicons=\"HashIcon\"\n        phosphor=\"Hash\"\n        remixicon=\"RiHashtag\"\n        {...p}\n      />\n    ),\n    label: \"acme-design\",\n    category: \"Channel\",\n  },\n  {\n    icon: (p: IconProps) => (\n      <IconPlaceholder\n        lucide=\"UserCog\"\n        tabler=\"IconUserCog\"\n        hugeicons=\"UserSettingsIcon\"\n        phosphor=\"UserGear\"\n        remixicon=\"RiUserSettingsLine\"\n        {...p}\n      />\n    ),\n    label: \"Account Settings\",\n    category: \"Settings\",\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-lg 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\">Type a command or search…</span>\n          <KbdGroup>\n            <Kbd>Ctrl</Kbd>\n            <Kbd>K</Kbd>\n          </KbdGroup>\n        </DialogTrigger>\n\n        <DialogContent\n          className=\"overflow-hidden p-0 sm:max-w-lg\"\n          showCloseButton={false}\n        >\n          <DialogTitle className=\"sr-only\">Command palette</DialogTitle>\n          <DialogDescription className=\"sr-only\">\n            Search recent items and results.\n          </DialogDescription>\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              <CommandGroup heading=\"Recent\" className={COMMAND_GROUP_CLASS}>\n                {recentItems.map((item) => (\n                  <CommandItem\n                    key={item.label}\n                    value={item.label}\n                    onSelect={() => run(item.label)}\n                    className={COMMAND_ITEM_CLASS}\n                  >\n                    <div className=\"flex size-7 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground group-data-selected/command-item:border-border group-data-selected/command-item:bg-background\">\n                      <item.icon className=\"size-3.5\" aria-hidden=\"true\" />\n                    </div>\n                    <span className=\"flex-1 truncate\">{item.label}</span>\n                    <span className=\"text-[10px] text-muted-foreground group-data-selected/command-item:text-foreground\">\n                      {item.time}\n                    </span>\n                    <IconPlaceholder\n                      lucide=\"ArrowRight\"\n                      tabler=\"IconArrowRight\"\n                      hugeicons=\"ArrowRightIcon\"\n                      phosphor=\"ArrowRight\"\n                      remixicon=\"RiArrowRightLine\"\n                      className=\"size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-data-selected/command-item:opacity-100\"\n                      aria-hidden=\"true\"\n                    />\n                  </CommandItem>\n                ))}\n              </CommandGroup>\n              <CommandSeparator />\n              <CommandGroup heading=\"Results\" className={COMMAND_GROUP_CLASS}>\n                {results.map((item) => (\n                  <CommandItem\n                    key={item.label}\n                    value={item.label}\n                    onSelect={() => run(item.label)}\n                    className={COMMAND_ITEM_CLASS}\n                  >\n                    <item.icon aria-hidden=\"true\" />\n                    <span className=\"flex-1 truncate\">{item.label}</span>\n                    <Badge\n                      variant=\"outline\"\n                      className=\"bg-background group-data-selected/command-item:border-border group-data-selected/command-item:bg-background group-data-selected/command-item:text-foreground\"\n                    >\n                      {item.category}\n                    </Badge>\n                    <CommandShortcut>\n                      <Kbd>↵</Kbd>\n                    </CommandShortcut>\n                  </CommandItem>\n                ))}\n              </CommandGroup>\n            </CommandList>\n\n            <div className=\"flex items-center gap-4 border-t border-border bg-muted/50 px-4 py-2\">\n              <span className=\"flex items-center gap-1.5 text-[10px] text-muted-foreground\">\n                <KbdGroup>\n                  <Kbd>↑</Kbd>\n                  <Kbd>↓</Kbd>\n                </KbdGroup>\n                to navigate\n              </span>\n              <span className=\"flex items-center gap-1.5 text-[10px] text-muted-foreground\">\n                <Kbd>↵</Kbd>\n                to open\n              </span>\n              <span className=\"ml-auto flex items-center gap-1.5 text-[10px] text-muted-foreground\">\n                <Kbd>Esc</Kbd>\n                to close\n              </span>\n            </div>\n          </Command>\n        </DialogContent>\n      </Dialog>\n      {ranLabel ? (\n        <p className=\"text-xs text-muted-foreground\">\n          Opened:{\" \"}\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-2.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"
}