{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"user-menus-sidebar-footer","type":"registry:component","title":"User menus · Sidebar footer","description":"User button for the bottom of a sidebar; the menu opens upward with a seat meter, and ArrowUp opens it on the last item.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"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":"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#sidebar-footer"}}