{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"user-menus","type":"registry:component","title":"User menus","description":"Three account menus — an avatar dropdown with workspace switcher and theme row, a sidebar footer menu that opens upward, and a searchable command-style profile menu — each springing from its trigger.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/examples/user-menus/avatar-dropdown.tsx","type":"registry:component","target":"components/examples/user-menus/avatar-dropdown.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { Check, ChevronDown, CreditCard, LogOut, Monitor, Moon, Plus, Settings, Sun, UserRound } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface MenuAccount {\n  id: string;\n  name: string;\n  plan: string;\n}\n\nexport type MenuTheme = \"light\" | \"dark\" | \"system\";\n\nexport interface AvatarDropdownProps {\n  name?: string;\n  email?: string;\n  accounts?: MenuAccount[];\n  defaultAccountId?: string;\n  defaultTheme?: MenuTheme;\n  /** Called with \"profile\", \"billing\", \"settings\", \"add-account\" or \"sign-out\". */\n  onSelect?: (action: string) => void;\n  onAccountChange?: (account: MenuAccount) => void;\n  /** Local preference only; wire it to your theme provider. */\n  onThemeChange?: (theme: MenuTheme) => void;\n  align?: \"start\" | \"end\";\n  /** Render open on mount (without moving focus), e.g. for previews. */\n  defaultOpen?: boolean;\n  className?: string;\n}\n\nconst ACCOUNTS: MenuAccount[] = [\n  { id: \"northwind\", name: \"Northwind Studio\", plan: \"Pro\" },\n  { id: \"halcyon\", name: \"Halcyon Labs\", plan: \"Team\" },\n  { id: \"personal\", name: \"Personal\", plan: \"Free\" },\n];\nconst THEMES = [\n  { id: \"light\", label: \"Light\", Icon: Sun },\n  { id: \"dark\", label: \"Dark\", Icon: Moon },\n  { id: \"system\", label: \"System\", Icon: Monitor },\n] as const;\nconst ITEMS = [\n  { id: \"profile\", label: \"Profile\", Icon: UserRound, kbd: \"⇧P\" },\n  { id: \"billing\", label: \"Billing\", Icon: CreditCard, kbd: \"⇧B\" },\n  { id: \"settings\", label: \"Settings\", Icon: Settings, kbd: \"⌘,\" },\n];\nconst spring = { type: \"spring\", stiffness: 420, damping: 32 } as const;\nconst initials = (n: string) => n.split(\" \").map((p) => p[0]).slice(0, 2).join(\"\");\n\n/** Avatar dropdown with an account switcher, a theme row and roving keyboard focus; the panel springs from the trigger corner. */\nexport function AvatarDropdown({\n  name = \"Maya Kerrigan\",\n  email = \"maya@northwind.studio\",\n  accounts = ACCOUNTS,\n  defaultAccountId = \"northwind\",\n  defaultTheme = \"system\",\n  onSelect,\n  onAccountChange,\n  onThemeChange,\n  align = \"end\",\n  defaultOpen = false,\n  className,\n}: AvatarDropdownProps) {\n  const reduce = useReducedMotion();\n  const uid = React.useId();\n  const [open, setOpen] = React.useState(defaultOpen);\n  const focusOnOpen = React.useRef(false);\n  const [account, setAccount] = React.useState(defaultAccountId);\n  const [theme, setTheme] = React.useState<MenuTheme>(defaultTheme);\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const triggerRef = React.useRef<HTMLButtonElement>(null);\n  const menuRef = React.useRef<HTMLDivElement>(null);\n  const current = accounts.find((a) => a.id === account) ?? accounts[0];\n\n  const items = () => Array.from(menuRef.current?.querySelectorAll<HTMLElement>(\"[data-item]\") ?? []);\n\n  React.useEffect(() => {\n    if (!open) return;\n    if (focusOnOpen.current) requestAnimationFrame(() => menuRef.current?.querySelector<HTMLElement>(\"[data-item]\")?.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(refocus = true) {\n    setOpen(false);\n    if (refocus) triggerRef.current?.focus();\n  }\n\n  function onKey(e: React.KeyboardEvent) {\n    const list = items();\n    const i = list.indexOf(document.activeElement as HTMLElement);\n    const go = (n: number) => list[(n + list.length) % list.length]?.focus();\n    if (e.key === \"ArrowDown\") go(i + 1);\n    else if (e.key === \"ArrowUp\") go(i - 1);\n    else if (e.key === \"Home\") go(0);\n    else if (e.key === \"End\") go(list.length - 1);\n    else if (e.key === \"Escape\") close();\n    else if (e.key === \"Tab\") return close(false);\n    else return;\n    e.preventDefault();\n  }\n\n  function act(id: string) {\n    onSelect?.(id);\n    close();\n  }\n\n  const row = \"flex w-full items-center gap-2.5 rounded-sm px-2.5 py-2 text-left text-[13px] text-ink outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover\";\n\n  return (\n    <div ref={rootRef} className={cn(\"relative inline-block\", className)}>\n      <motion.button\n        ref={triggerRef}\n        type=\"button\"\n        aria-haspopup=\"menu\"\n        aria-expanded={open}\n        aria-controls={`${uid}-menu`}\n        whileTap={{ scale: 0.96 }}\n        onClick={() => {\n          focusOnOpen.current = true;\n          setOpen((o) => !o);\n        }}\n        onKeyDown={(e) => {\n          if (e.key !== \"ArrowDown\") return;\n          e.preventDefault();\n          focusOnOpen.current = true;\n          setOpen(true);\n        }}\n        className=\"flex items-center gap-2 rounded-full border border-border bg-surface-raised py-1 pl-1 pr-2.5 shadow-sm outline-none transition-colors hover:bg-surface-hover focus-visible:shadow-[var(--focus-ring)]\"\n      >\n        <span aria-hidden className=\"grid size-7 place-items-center rounded-full bg-ink text-[11px] font-semibold text-bg\">{initials(name)}</span>\n        <span className=\"text-[13px] font-medium text-ink\">{name.split(\" \")[0]}</span>\n        <motion.span aria-hidden animate={{ rotate: open ? 180 : 0 }} transition={spring} className=\"text-ink-subtle\">\n          <ChevronDown className=\"size-3.5\" />\n        </motion.span>\n      </motion.button>\n\n      <AnimatePresence>\n        {open && (\n          <motion.div\n            ref={menuRef}\n            id={`${uid}-menu`}\n            role=\"menu\"\n            aria-label=\"Account\"\n            onKeyDown={onKey}\n            initial={{ opacity: 0, scale: reduce ? 1 : 0.94, y: reduce ? 0 : -6 }}\n            animate={{ opacity: 1, scale: 1, y: 0 }}\n            exit={{ opacity: 0, scale: reduce ? 1 : 0.96, y: reduce ? 0 : -4, transition: { duration: 0.12 } }}\n            transition={spring}\n            style={{ transformOrigin: align === \"end\" ? \"top right\" : \"top left\" }}\n            className={cn(\"absolute top-full z-30 mt-2 w-[min(288px,calc(100vw-32px))] rounded-md border border-border bg-surface-raised p-1.5 shadow-lg\", align === \"end\" ? \"right-0\" : \"left-0\")}\n          >\n            <div className=\"px-2.5 pb-2 pt-1.5\">\n              <p className=\"text-[13.5px] font-semibold text-ink\">{name}</p>\n              <p className=\"truncate text-[12px] text-ink-subtle\">{email}</p>\n            </div>\n            <div className=\"h-px bg-border\" />\n            <p className=\"px-2.5 pb-1 pt-2 text-[11px] font-medium text-ink-subtle\">Workspaces</p>\n            <div role=\"group\" aria-label=\"Workspaces\">\n              {accounts.map((a) => (\n                <button\n                  key={a.id}\n                  type=\"button\"\n                  role=\"menuitemradio\"\n                  aria-checked={a.id === account}\n                  data-item\n                  tabIndex={-1}\n                  onClick={() => {\n                    setAccount(a.id);\n                    onAccountChange?.(a);\n                  }}\n                  className={row}\n                >\n                  <span aria-hidden className=\"grid size-6 place-items-center rounded-xs bg-surface-sunken text-[10.5px] font-semibold text-ink-muted ring-1 ring-border\">{initials(a.name)}</span>\n                  <span className=\"flex-1 truncate\">{a.name}</span>\n                  <span className=\"text-[11px] text-ink-subtle\">{a.plan}</span>\n                  <span className=\"grid size-4 place-items-center\">\n                    {a.id === current.id && (\n                      <motion.span layoutId={`${uid}-check`} transition={spring}>\n                        <Check aria-hidden className=\"size-4 text-volt-ink\" />\n                      </motion.span>\n                    )}\n                  </span>\n                </button>\n              ))}\n              <button type=\"button\" role=\"menuitem\" data-item tabIndex={-1} onClick={() => act(\"add-account\")} className={cn(row, \"text-ink-muted\")}>\n                <span aria-hidden className=\"grid size-6 place-items-center rounded-xs border border-dashed border-border-strong\"><Plus className=\"size-3.5\" /></span>\n                Add workspace\n              </button>\n            </div>\n            <div className=\"my-1.5 h-px bg-border\" />\n            {ITEMS.map(({ id, label, Icon, kbd }) => (\n              <button key={id} type=\"button\" role=\"menuitem\" data-item tabIndex={-1} onClick={() => act(id)} className={row}>\n                <Icon aria-hidden className=\"size-4 text-ink-subtle\" />\n                <span className=\"flex-1\">{label}</span>\n                <kbd className=\"font-mono text-[11px] text-ink-subtle\">{kbd}</kbd>\n              </button>\n            ))}\n            <div className=\"flex items-center justify-between gap-2 px-2.5 py-1.5\">\n              <span className=\"text-[13px] text-ink\">Theme</span>\n              <div role=\"group\" aria-label=\"Theme\" className=\"flex rounded-full border border-border bg-surface-sunken p-0.5\">\n                {THEMES.map(({ id, label, Icon }) => (\n                  <button\n                    key={id}\n                    type=\"button\"\n                    role=\"menuitemradio\"\n                    aria-checked={theme === id}\n                    aria-label={label}\n                    data-item\n                    tabIndex={-1}\n                    onClick={() => {\n                      setTheme(id);\n                      onThemeChange?.(id);\n                    }}\n                    className=\"relative grid size-7 place-items-center rounded-full outline-none focus-visible:shadow-[var(--focus-ring)]\"\n                  >\n                    {theme === id && <motion.span layoutId={`${uid}-theme`} transition={spring} className=\"absolute inset-0 rounded-full bg-surface-raised shadow-sm ring-1 ring-border\" />}\n                    <Icon aria-hidden className={cn(\"relative size-3.5\", theme === id ? \"text-ink\" : \"text-ink-subtle\")} />\n                  </button>\n                ))}\n              </div>\n            </div>\n            <div className=\"my-1.5 h-px bg-border\" />\n            <button type=\"button\" role=\"menuitem\" data-item tabIndex={-1} onClick={() => act(\"sign-out\")} className={row}>\n              <LogOut aria-hidden className=\"size-4 text-ink-subtle\" />\n              Sign out\n            </button>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n"},{"path":"registry/geturui/examples/user-menus/sidebar-footer.tsx","type":"registry:component","target":"components/examples/user-menus/sidebar-footer.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { Bell, BookOpen, ChevronsUpDown, Keyboard, LogOut, Sparkles, UserRound } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface SidebarUserMenuItem {\n  id: string;\n  label: string;\n  icon?: React.ComponentType<{ className?: string }>;\n  /** Small count shown at the end of the row. */\n  badge?: number;\n}\n\nexport interface SidebarUserMenuProps {\n  name?: string;\n  email?: string;\n  plan?: string;\n  seatsUsed?: number;\n  seatsTotal?: number;\n  items?: SidebarUserMenuItem[];\n  /** Called with the item id, \"upgrade\" or \"sign-out\". */\n  onSelect?: (id: string) => void;\n  /** Render open on mount (without moving focus), e.g. for previews. */\n  defaultOpen?: boolean;\n  className?: string;\n}\n\nconst ITEMS: SidebarUserMenuItem[] = [\n  { id: \"account\", label: \"Account\", icon: UserRound },\n  { id: \"notifications\", label: \"Notifications\", icon: Bell, badge: 3 },\n  { id: \"shortcuts\", label: \"Keyboard shortcuts\", icon: Keyboard },\n  { id: \"docs\", label: \"Help and docs\", icon: BookOpen },\n];\nconst spring = { type: \"spring\", stiffness: 380, damping: 30 } as const;\n\n/** Sidebar footer user button whose menu opens upward with a seat meter; ArrowUp opens it focused on the last item. */\nexport function SidebarUserMenu({\n  name = \"Jordan Okafor\",\n  email = \"jordan@relaybase.io\",\n  plan = \"Team plan\",\n  seatsUsed = 8,\n  seatsTotal = 10,\n  items = ITEMS,\n  onSelect,\n  defaultOpen = false,\n  className,\n}: SidebarUserMenuProps) {\n  const reduce = useReducedMotion();\n  const uid = React.useId();\n  const [open, setOpen] = React.useState(defaultOpen);\n  const focusOnOpen = React.useRef(false);\n  const startAt = React.useRef<\"first\" | \"last\">(\"first\");\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const triggerRef = React.useRef<HTMLButtonElement>(null);\n  const menuRef = React.useRef<HTMLDivElement>(null);\n  const initials = name.split(\" \").map((p) => p[0]).slice(0, 2).join(\"\");\n\n  React.useEffect(() => {\n    if (!open) return;\n    if (focusOnOpen.current)\n      requestAnimationFrame(() => {\n        const list = menuRef.current?.querySelectorAll<HTMLElement>('[role=\"menuitem\"]');\n        if (list?.length) list[startAt.current === \"last\" ? list.length - 1 : 0].focus();\n      });\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 openAt(where: \"first\" | \"last\") {\n    startAt.current = where;\n    focusOnOpen.current = true;\n    setOpen(true);\n  }\n\n  function close(refocus = true) {\n    setOpen(false);\n    if (refocus) triggerRef.current?.focus();\n  }\n\n  function onKey(e: React.KeyboardEvent) {\n    const list = Array.from(menuRef.current?.querySelectorAll<HTMLElement>('[role=\"menuitem\"]') ?? []);\n    const i = list.indexOf(document.activeElement as HTMLElement);\n    const go = (n: number) => list[(n + list.length) % list.length]?.focus();\n    if (e.key === \"ArrowDown\") go(i + 1);\n    else if (e.key === \"ArrowUp\") go(i - 1);\n    else if (e.key === \"Home\") go(0);\n    else if (e.key === \"End\") go(list.length - 1);\n    else if (e.key === \"Escape\") close();\n    else if (e.key === \"Tab\") return close(false);\n    else return;\n    e.preventDefault();\n  }\n\n  function act(id: string) {\n    onSelect?.(id);\n    close();\n  }\n\n  const row = \"flex w-full items-center gap-2.5 rounded-sm px-2.5 py-2 text-left text-[13px] text-ink outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover\";\n  const pct = Math.min(100, (seatsUsed / seatsTotal) * 100);\n\n  return (\n    <div ref={rootRef} className={cn(\"relative w-full max-w-[260px]\", className)}>\n      <AnimatePresence>\n        {open && (\n          <motion.div\n            ref={menuRef}\n            id={`${uid}-menu`}\n            role=\"menu\"\n            aria-label={`${name} account`}\n            onKeyDown={onKey}\n            initial={{ opacity: 0, y: reduce ? 0 : 10, scale: reduce ? 1 : 0.97 }}\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            exit={{ opacity: 0, y: reduce ? 0 : 6, scale: reduce ? 1 : 0.98, transition: { duration: 0.12 } }}\n            transition={spring}\n            style={{ transformOrigin: \"bottom center\" }}\n            className=\"absolute inset-x-0 bottom-full z-30 mb-2 rounded-md border border-border bg-surface-raised p-1.5 shadow-lg\"\n          >\n            <div className=\"rounded-sm bg-surface-sunken p-2.5\">\n              <div className=\"flex items-center justify-between text-[12px]\">\n                <span className=\"font-medium text-ink\">{plan}</span>\n                <span className=\"tabular-nums text-ink-subtle\">{seatsUsed} of {seatsTotal} seats</span>\n              </div>\n              <div role=\"meter\" aria-label=\"Seats used\" aria-valuemin={0} aria-valuemax={seatsTotal} aria-valuenow={seatsUsed} className=\"mt-2 h-1.5 overflow-hidden rounded-full bg-border\">\n                <motion.div initial={{ scaleX: 0 }} animate={{ scaleX: pct / 100 }} transition={{ ...spring, delay: 0.08 }} style={{ transformOrigin: \"left\" }} className=\"h-full rounded-full bg-volt\" />\n              </div>\n              <button type=\"button\" role=\"menuitem\" tabIndex={-1} onClick={() => act(\"upgrade\")} className=\"mt-2.5 inline-flex items-center gap-1.5 rounded-xs text-[12px] font-medium text-volt-ink outline-none hover:underline focus-visible:shadow-[var(--focus-ring)]\">\n                <Sparkles aria-hidden className=\"size-3.5\" />\n                Add more seats\n              </button>\n            </div>\n            <div className=\"mt-1.5 space-y-0.5\">\n              {items.map(({ id, label, icon: Icon, badge }) => (\n                <button key={id} type=\"button\" role=\"menuitem\" tabIndex={-1} onClick={() => act(id)} className={row}>\n                  {Icon && <Icon className=\"size-4 text-ink-subtle\" />}\n                  <span className=\"flex-1\">{label}</span>\n                  {badge ? <span className=\"rounded-full bg-surface-sunken px-1.5 text-[11px] font-medium tabular-nums text-ink-muted ring-1 ring-border\">{badge}</span> : null}\n                </button>\n              ))}\n            </div>\n            <div className=\"my-1.5 h-px bg-border\" />\n            <button type=\"button\" role=\"menuitem\" tabIndex={-1} onClick={() => act(\"sign-out\")} className={row}>\n              <LogOut aria-hidden className=\"size-4 text-ink-subtle\" />\n              Log out\n            </button>\n          </motion.div>\n        )}\n      </AnimatePresence>\n\n      <motion.button\n        ref={triggerRef}\n        type=\"button\"\n        aria-haspopup=\"menu\"\n        aria-expanded={open}\n        aria-controls={`${uid}-menu`}\n        whileTap={{ scale: 0.98 }}\n        onClick={() => (open ? close() : openAt(\"first\"))}\n        onKeyDown={(e) => {\n          if (e.key !== \"ArrowUp\" && e.key !== \"ArrowDown\") return;\n          e.preventDefault();\n          openAt(e.key === \"ArrowUp\" ? \"last\" : \"first\");\n        }}\n        className={cn(\n          \"flex w-full items-center gap-2.5 rounded-md p-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:shadow-[var(--focus-ring)]\",\n          open && \"bg-surface-hover\",\n        )}\n      >\n        <span aria-hidden className=\"relative grid size-9 shrink-0 place-items-center rounded-full bg-ink text-[12px] font-semibold text-bg\">\n          {initials}\n          <span className=\"absolute -bottom-0.5 -right-0.5 size-3 rounded-full border-2 border-surface-raised bg-success\" />\n        </span>\n        <span className=\"min-w-0 flex-1\">\n          <span className=\"block truncate text-[13px] font-medium text-ink\">{name}</span>\n          <span className=\"block truncate text-[11.5px] text-ink-subtle\">{email}</span>\n        </span>\n        <ChevronsUpDown aria-hidden className=\"size-4 shrink-0 text-ink-subtle\" />\n      </motion.button>\n    </div>\n  );\n}\n"},{"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"}}