{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"user-menus-command-profile","type":"registry:component","title":"User menus · Command profile","description":"Profile menu with a search field: type to filter grouped actions, a highlight slides between rows and every action shows its shortcut.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/examples/user-menus/command-profile.tsx","type":"registry:component","target":"components/examples/user-menus/command-profile.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { CircleDot, CreditCard, LogOut, Moon, Search, Settings, UserRound, UsersRound } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface CommandProfileAction {\n  id: string;\n  label: string;\n  group: string;\n  icon?: React.ComponentType<{ className?: string }>;\n  /** Keys shown on the right, e.g. [\"G\", \"P\"]. */\n  keys?: string[];\n}\n\nexport interface CommandProfileMenuProps {\n  name?: string;\n  handle?: string;\n  actions?: CommandProfileAction[];\n  onSelect?: (action: CommandProfileAction) => void;\n  /** Render open on mount (without moving focus), e.g. for previews. */\n  defaultOpen?: boolean;\n  className?: string;\n}\n\nconst ACTIONS: CommandProfileAction[] = [\n  { id: \"profile\", label: \"View profile\", group: \"Account\", icon: UserRound, keys: [\"G\", \"P\"] },\n  { id: \"status\", label: \"Set status\", group: \"Account\", icon: CircleDot, keys: [\"S\"] },\n  { id: \"dnd\", label: \"Pause notifications\", group: \"Account\", icon: Moon, keys: [\"⇧\", \"D\"] },\n  { id: \"team\", label: \"Invite teammates\", group: \"Workspace\", icon: UsersRound, keys: [\"I\"] },\n  { id: \"billing\", label: \"Billing and usage\", group: \"Workspace\", icon: CreditCard, keys: [\"G\", \"B\"] },\n  { id: \"settings\", label: \"Settings\", group: \"Workspace\", icon: Settings, keys: [\"⌘\", \",\"] },\n  { id: \"sign-out\", label: \"Sign out\", group: \"Session\", icon: LogOut, keys: [\"⇧\", \"Q\"] },\n];\nconst spring = { type: \"spring\", stiffness: 480, damping: 36 } as const;\n\n/** Command-style profile menu: type to filter, arrows move a sliding highlight, Enter runs, Escape clears then closes. */\nexport function CommandProfileMenu({ name = \"Priya Raman\", handle = \"@priya\", actions = ACTIONS, onSelect, defaultOpen = false, className }: CommandProfileMenuProps) {\n  const reduce = useReducedMotion();\n  const uid = React.useId();\n  const [open, setOpen] = React.useState(defaultOpen);\n  const focusOnOpen = React.useRef(false);\n  const [query, setQuery] = React.useState(\"\");\n  const [active, setActive] = React.useState(0);\n  const [ran, setRan] = React.useState<string | null>(null);\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const triggerRef = React.useRef<HTMLButtonElement>(null);\n  const inputRef = React.useRef<HTMLInputElement>(null);\n  const initials = name.split(\" \").map((p) => p[0]).slice(0, 2).join(\"\");\n\n  const results = actions.filter((a) => a.label.toLowerCase().includes(query.trim().toLowerCase()));\n  const groups = [...new Set(results.map((a) => a.group))];\n\n  React.useEffect(() => {\n    if (!open) return;\n    if (focusOnOpen.current) requestAnimationFrame(() => inputRef.current?.focus());\n    const onDown = (e: PointerEvent) => !rootRef.current?.contains(e.target as Node) && setOpen(false);\n    document.addEventListener(\"pointerdown\", onDown);\n    return () => document.removeEventListener(\"pointerdown\", onDown);\n  }, [open]);\n\n  function close() {\n    setOpen(false);\n    setQuery(\"\");\n    setActive(0);\n    triggerRef.current?.focus();\n  }\n\n  function run(a: CommandProfileAction | undefined) {\n    if (!a) return;\n    onSelect?.(a);\n    setRan(a.label);\n    close();\n  }\n\n  function onKey(e: React.KeyboardEvent) {\n    const n = results.length;\n    if (e.key === \"ArrowDown\") setActive((i) => (i + 1) % Math.max(n, 1));\n    else if (e.key === \"ArrowUp\") setActive((i) => (i - 1 + n) % Math.max(n, 1));\n    else if (e.key === \"Home\") setActive(0);\n    else if (e.key === \"End\") setActive(n - 1);\n    else if (e.key === \"Enter\") run(results[active]);\n    else if (e.key === \"Escape\" && query) {\n      setQuery(\"\");\n      setActive(0);\n    } else if (e.key === \"Escape\") close();\n    else if (e.key === \"Tab\") return setOpen(false);\n    else return;\n    e.preventDefault();\n  }\n\n  return (\n    <div ref={rootRef} className={cn(\"relative inline-flex flex-col items-start gap-2\", className)}>\n      <motion.button\n        ref={triggerRef}\n        type=\"button\"\n        aria-haspopup=\"dialog\"\n        aria-expanded={open}\n        aria-label={`Open profile menu for ${name}`}\n        whileTap={{ scale: 0.94 }}\n        onClick={() => {\n          if (open) return close();\n          focusOnOpen.current = true;\n          setOpen(true);\n        }}\n        className=\"grid size-10 place-items-center rounded-full bg-ink text-[13px] font-semibold text-bg shadow-sm outline-none ring-2 ring-surface-raised focus-visible:shadow-[var(--focus-ring)]\"\n      >\n        {initials}\n      </motion.button>\n      <p aria-live=\"polite\" className=\"sr-only\">{ran ? `${ran} selected` : \"\"}</p>\n\n      <AnimatePresence>\n        {open && (\n          <motion.div\n            role=\"dialog\"\n            aria-label=\"Profile commands\"\n            initial={{ opacity: 0, y: reduce ? 0 : -8, scale: reduce ? 1 : 0.96, filter: \"blur(6px)\" }}\n            animate={{ opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" }}\n            exit={{ opacity: 0, y: reduce ? 0 : -4, scale: reduce ? 1 : 0.98, transition: { duration: 0.12 } }}\n            transition={spring}\n            style={{ transformOrigin: \"top left\" }}\n            className=\"absolute left-0 top-12 z-30 w-[min(320px,calc(100vw-32px))] overflow-hidden rounded-md border border-border bg-surface-raised shadow-lg\"\n          >\n            <div className=\"flex items-center gap-3 border-b border-border p-3\">\n              <span aria-hidden className=\"grid size-9 place-items-center rounded-full bg-ink text-[12px] font-semibold text-bg\">{initials}</span>\n              <div className=\"min-w-0\">\n                <p className=\"truncate text-[13.5px] font-semibold text-ink\">{name}</p>\n                <p className=\"text-[12px] text-ink-subtle\">{handle}</p>\n              </div>\n            </div>\n            <label className=\"flex items-center gap-2 border-b border-border px-3\">\n              <Search aria-hidden className=\"size-4 text-ink-subtle\" />\n              <span className=\"sr-only\">Search profile actions</span>\n              <input\n                ref={inputRef}\n                role=\"combobox\"\n                aria-expanded\n                aria-controls={`${uid}-list`}\n                aria-activedescendant={results[active] ? `${uid}-${results[active].id}` : undefined}\n                value={query}\n                onChange={(e) => {\n                  setQuery(e.target.value);\n                  setActive(0);\n                }}\n                onKeyDown={onKey}\n                placeholder=\"Search actions\"\n                className=\"h-11 w-full bg-transparent text-[13.5px] text-ink outline-none placeholder:text-ink-subtle\"\n              />\n              <kbd className=\"rounded-xs border border-border px-1.5 font-mono text-[10.5px] text-ink-subtle\">esc</kbd>\n            </label>\n            <div id={`${uid}-list`} role=\"listbox\" aria-label=\"Actions\" className=\"max-h-[340px] overflow-y-auto p-1.5\">\n              {results.length === 0 && <p className=\"px-2.5 py-6 text-center text-[13px] text-ink-subtle\">No actions match “{query}”.</p>}\n              {groups.map((g) => (\n                <div key={g} role=\"group\" aria-label={g}>\n                  <p aria-hidden className=\"px-2.5 pb-1 pt-2 text-[11px] font-medium text-ink-subtle\">{g}</p>\n                  {results.filter((a) => a.group === g).map((a) => {\n                    const i = results.indexOf(a);\n                    const on = i === active;\n                    const Icon = a.icon;\n                    return (\n                      <div\n                        key={a.id}\n                        id={`${uid}-${a.id}`}\n                        role=\"option\"\n                        aria-selected={on}\n                        onPointerMove={() => setActive(i)}\n                        onClick={() => run(a)}\n                        className=\"relative flex cursor-pointer items-center gap-2.5 rounded-sm px-2.5 py-2 text-[13px]\"\n                      >\n                        {on && <motion.span layoutId={`${uid}-hl`} transition={spring} className=\"absolute inset-0 rounded-sm bg-surface-hover ring-1 ring-border\" />}\n                        {Icon && <Icon className={cn(\"relative size-4\", on ? \"text-ink\" : \"text-ink-subtle\")} />}\n                        <span className={cn(\"relative flex-1\", on ? \"text-ink\" : \"text-ink-muted\")}>{a.label}</span>\n                        <span className=\"relative flex gap-1\">\n                          {a.keys?.map((k) => (\n                            <kbd key={k} className=\"grid h-5 min-w-5 place-items-center rounded-xs border border-border bg-surface-sunken px-1 font-mono text-[10.5px] text-ink-subtle\">{k}</kbd>\n                          ))}\n                        </span>\n                      </div>\n                    );\n                  })}\n                </div>\n              ))}\n            </div>\n            <div className=\"flex items-center justify-between border-t border-border bg-surface px-3 py-2 text-[11px] text-ink-subtle\">\n              <span>↑↓ to move · ↵ to run</span>\n              <span>{results.length} actions</span>\n            </div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n"},{"path":"LICENSE-geturui.md","type":"registry:file","target":"LICENSE-geturui.md","content":"MIT License\n\nCopyright (c) 2026 geturui.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"}],"categories":["examples","user menu","account","avatar","dropdown","profile","workspace switcher","sidebar","command","menu"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/user-menus#command-profile"}}