{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sidebar-floating",
  "type": "registry:component",
  "title": "Sidebar Floating",
  "description": "A frosted, rounded sidebar inset from the page edge with labeled groups, an active pill that glides between items and a user card with a live status dot.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "sidebars",
    "sidebar",
    "floating",
    "glass",
    "navigation",
    "dashboard",
    "pill"
  ],
  "docs": "https://hyperblur.dev/effects/sidebar-floating",
  "files": [
    {
      "path": "registry/hyperblur/sidebar-floating.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/sidebar-floating.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nconst ICONS = {\n  home: \"M3.5 9.2L10 3.8l6.5 5.4V16a.8.8 0 0 1-.8.8H12v-4.5H8v4.5H4.3a.8.8 0 0 1-.8-.8z\",\n  inbox:\n    \"M3.5 11.5h3.2l.9 1.8h4.8l.9-1.8h3.2M3.5 11.5l1.8-6.2a1 1 0 0 1 1-.7h7.4a1 1 0 0 1 1 .7l1.8 6.2v3.7a1 1 0 0 1-1 1H4.5a1 1 0 0 1-1-1z\",\n  folder:\n    \"M3 6.2a1.5 1.5 0 0 1 1.5-1.5h3.1l1.6 1.8h5.8A1.5 1.5 0 0 1 16.5 8v6.3a1.5 1.5 0 0 1-1.5 1.5H4.5A1.5 1.5 0 0 1 3 14.3z\",\n  chart: \"M4 16V9M10 16V4M16 16v-5\",\n  users:\n    \"M7.5 9a2.7 2.7 0 1 0 0-5.4 2.7 2.7 0 0 0 0 5.4zM2.5 16.2c.4-2.7 2.5-4.2 5-4.2s4.6 1.5 5 4.2M13 4.2a2.7 2.7 0 0 1 0 5M14.5 12.2c1.6.5 2.7 1.8 3 4\",\n  calendar:\n    \"M4.5 5h11a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1zM3.5 8.5h13M7 3.5v3M13 3.5v3\",\n  sliders: \"M4 6h7M14 6h2M4 14h2M9 14h7M12.5 4v4M7.5 12v4\",\n  bell: \"M5.5 8.5a4.5 4.5 0 0 1 9 0c0 4 1.5 5 1.5 5h-12s1.5-1 1.5-5zM8.5 16a1.7 1.7 0 0 0 3 0\",\n  star: \"M10 3.5l2 4.2 4.5.6-3.3 3.1.8 4.5L10 13.7l-4 2.2.8-4.5L3.5 8.3l4.5-.6z\",\n  layers: \"M10 3.5l6.5 3.3L10 10 3.5 6.8zM3.5 10.2L10 13.5l6.5-3.3M3.5 13.4L10 16.7l6.5-3.3\",\n} as const;\n\nexport type SidebarFloatingIconName = keyof typeof ICONS;\n\nexport function SidebarFloatingIcon({ name }: { name: SidebarFloatingIconName }) {\n  return (\n    <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n      <path d={ICONS[name]} />\n    </svg>\n  );\n}\n\nexport interface SidebarFloatingItem {\n  id: string;\n  label: string;\n  icon?: React.ReactNode;\n  badge?: string | number;\n  href?: string;\n}\n\nexport interface SidebarFloatingGroup {\n  label?: string;\n  items: SidebarFloatingItem[];\n}\n\nexport interface SidebarFloatingUser {\n  name: string;\n  role?: string;\n  color?: string;\n  status?: \"online\" | \"away\" | \"offline\";\n}\n\nexport interface SidebarFloatingProps\n  extends Omit<React.HTMLAttributes<HTMLElement>, \"onChange\" | \"children\" | \"defaultValue\"> {\n  groups?: SidebarFloatingGroup[];\n  active?: string;\n  defaultActive?: string;\n  onChange?: (id: string) => void;\n  brand?: React.ReactNode;\n  user?: SidebarFloatingUser | null;\n  onUserClick?: () => void;\n  width?: number;\n  inset?: number;\n  rowHeight?: number;\n  color?: string;\n}\n\nconst defaultGroups: SidebarFloatingGroup[] = [\n  {\n    label: \"Workspace\",\n    items: [\n      { id: \"home\", label: \"Overview\", icon: <SidebarFloatingIcon name=\"home\" /> },\n      { id: \"inbox\", label: \"Inbox\", icon: <SidebarFloatingIcon name=\"inbox\" />, badge: 4 },\n      { id: \"calendar\", label: \"Calendar\", icon: <SidebarFloatingIcon name=\"calendar\" /> },\n    ],\n  },\n  {\n    label: \"Manage\",\n    items: [\n      { id: \"projects\", label: \"Projects\", icon: <SidebarFloatingIcon name=\"folder\" /> },\n      { id: \"reports\", label: \"Reports\", icon: <SidebarFloatingIcon name=\"chart\" /> },\n      { id: \"team\", label: \"Team\", icon: <SidebarFloatingIcon name=\"users\" /> },\n    ],\n  },\n];\n\nconst defaultUser: SidebarFloatingUser = { name: \"Maya Jensen\", role: \"Product designer\", status: \"online\" };\n\nconst css = `\n.hb-sbf {\n  position: relative;\n  display: flex;\n  box-sizing: border-box;\n  width: var(--hb-sbf-w, 248px);\n  max-width: 100%;\n  height: 100%;\n  min-height: 0;\n  padding: var(--hb-sbf-inset, 12px);\n  color: #ededed;\n  font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);\n  font-size: 13px;\n  line-height: 18px;\n  --hb-sbf-accent: #2f7bff;\n}\n.hb-sbf *, .hb-sbf *::before, .hb-sbf *::after { box-sizing: border-box; }\n.hb-sbf-panel {\n  position: relative;\n  display: flex;\n  flex: 1;\n  flex-direction: column;\n  min-width: 0;\n  min-height: 0;\n  padding: 8px;\n  border: 1px solid rgba(255, 255, 255, .09);\n  border-radius: 18px;\n  background: linear-gradient(180deg, rgba(36, 36, 41, .74), rgba(16, 16, 19, .7));\n  -webkit-backdrop-filter: blur(20px) saturate(1.5);\n  backdrop-filter: blur(20px) saturate(1.5);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 22px 44px -10px rgba(0, 0, 0, .65), 0 2px 8px rgba(0, 0, 0, .35);\n}\n.hb-sbf-brand { display: flex; flex: none; align-items: center; gap: 8px; min-width: 0; padding: 4px 8px 8px; font-weight: 600; }\n.hb-sbf-nav {\n  position: relative;\n  display: flex;\n  flex: 1;\n  flex-direction: column;\n  gap: 10px;\n  min-height: 0;\n  overflow-y: auto;\n  scrollbar-width: none;\n}\n.hb-sbf-nav::-webkit-scrollbar { display: none; }\n.hb-sbf-pill {\n  position: absolute;\n  top: 0;\n  left: 0;\n  right: 0;\n  height: var(--hb-sbf-ph, 0px);\n  border: 1px solid rgba(47, 123, 255, .38);\n  border-radius: 11px;\n  background: linear-gradient(180deg, rgba(47, 123, 255, .3), rgba(47, 123, 255, .14));\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-sbf-accent) 30%, transparent), color-mix(in srgb, var(--hb-sbf-accent) 14%, transparent));\n  border-color: color-mix(in srgb, var(--hb-sbf-accent) 40%, transparent);\n  box-shadow: 0 0 22px -6px var(--hb-sbf-accent), inset 0 1px 0 rgba(255, 255, 255, .12);\n  opacity: 0;\n  pointer-events: none;\n  transform: translate3d(0, var(--hb-sbf-py, 0px), 0);\n  transition: transform .38s cubic-bezier(.34, 1.4, .5, 1), height .3s cubic-bezier(.2, .9, .2, 1), opacity .2s ease;\n}\n.hb-sbf-pill[data-ready=\"true\"] { opacity: 1; }\n.hb-sbf-group { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }\n.hb-sbf-label {\n  height: var(--hb-sbf-lh, 20px);\n  padding: 0 10px;\n  color: #77777f;\n  font-size: 10.5px;\n  font-weight: 600;\n  letter-spacing: .08em;\n  line-height: var(--hb-sbf-lh, 20px);\n  text-transform: uppercase;\n}\n.hb-sbf-item {\n  position: relative;\n  z-index: 1;\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  width: 100%;\n  height: var(--hb-sbf-row, 36px);\n  margin: 0;\n  padding: 0 10px;\n  border: 0;\n  border-radius: 11px;\n  background: transparent;\n  color: #9c9ca5;\n  font: inherit;\n  font-weight: 500;\n  text-align: left;\n  text-decoration: none;\n  cursor: pointer;\n  transition: color .18s ease, background-color .18s ease;\n  -webkit-tap-highlight-color: transparent;\n}\n.hb-sbf-item:hover { background: rgba(255, 255, 255, .05); color: #f4f4f5; }\n.hb-sbf-item[aria-current=\"page\"] { background: transparent; color: #ffffff; }\n.hb-sbf-item:focus-visible { outline: 2px solid var(--hb-sbf-accent); outline-offset: -1px; }\n.hb-sbf-ico { display: grid; flex: none; place-items: center; width: 18px; height: 18px; }\n.hb-sbf-ico svg { width: 18px; height: 18px; transition: transform .25s cubic-bezier(.34, 1.56, .64, 1); }\n.hb-sbf-item:hover .hb-sbf-ico svg { transform: scale(1.1); }\n.hb-sbf-letter { display: grid; place-items: center; width: 18px; height: 18px; border: 1px solid currentColor; border-radius: 6px; font-size: 10px; line-height: 1; }\n.hb-sbf-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-sbf-badge {\n  flex: none;\n  min-width: 18px;\n  padding: 0 6px;\n  border-radius: 999px;\n  background: rgba(255, 255, 255, .1);\n  color: #e4e4e7;\n  font-size: 11px;\n  font-weight: 600;\n  line-height: 18px;\n  text-align: center;\n  transition: background-color .2s ease, color .2s ease;\n}\n.hb-sbf-item[aria-current=\"page\"] .hb-sbf-badge { background: var(--hb-sbf-accent); color: #ffffff; }\n.hb-sbf-user {\n  position: relative;\n  display: flex;\n  flex: none;\n  align-items: center;\n  gap: 9px;\n  width: 100%;\n  margin: 8px 0 0;\n  padding: 7px 8px;\n  border: 1px solid rgba(255, 255, 255, .07);\n  border-radius: 13px;\n  background: rgba(255, 255, 255, .04);\n  color: inherit;\n  font: inherit;\n  text-align: left;\n  cursor: pointer;\n  transition: background-color .18s ease, border-color .18s ease;\n  -webkit-tap-highlight-color: transparent;\n}\n.hb-sbf-user:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .12); }\n.hb-sbf-user:focus-visible { outline: 2px solid var(--hb-sbf-accent); outline-offset: 1px; }\n.hb-sbf-avatar {\n  position: relative;\n  display: grid;\n  flex: none;\n  place-items: center;\n  width: 30px;\n  height: 30px;\n  border-radius: 999px;\n  color: #ffffff;\n  font-size: 11px;\n  font-weight: 700;\n  letter-spacing: .02em;\n  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);\n}\n.hb-sbf-dot {\n  position: absolute;\n  right: -1px;\n  bottom: -1px;\n  width: 10px;\n  height: 10px;\n  border: 2px solid #17171a;\n  border-radius: 999px;\n  background: var(--hb-sbf-status, #3ecf8e);\n}\n.hb-sbf-dot[data-status=\"online\"]::after {\n  content: \"\";\n  position: absolute;\n  inset: -2px;\n  border-radius: 999px;\n  border: 1px solid #3ecf8e;\n  animation: hb-sbf-ping 2.2s ease-out infinite;\n}\n.hb-sbf-who { display: flex; flex: 1; flex-direction: column; min-width: 0; }\n.hb-sbf-name { overflow: hidden; font-size: 12.5px; font-weight: 600; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }\n.hb-sbf-role { overflow: hidden; color: #8a8a93; font-size: 11px; line-height: 14px; text-overflow: ellipsis; white-space: nowrap; }\n.hb-sbf-more { flex: none; width: 14px; height: 14px; color: #77777f; }\n@keyframes hb-sbf-ping {\n  0% { opacity: .9; transform: scale(.8); }\n  80%, 100% { opacity: 0; transform: scale(1.7); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-sbf-pill, .hb-sbf-item, .hb-sbf-ico svg, .hb-sbf-badge, .hb-sbf-user { transition: none; }\n  .hb-sbf-dot[data-status=\"online\"]::after { animation: none; display: none; }\n}\n`;\n\nfunction hashName(value: string) {\n  let h = 7;\n  for (let i = 0; i < value.length; i += 1) h = (Math.imul(h, 31) + value.charCodeAt(i)) >>> 0;\n  return h % 360;\n}\n\nfunction initialsOf(name: string) {\n  const parts = name.trim().split(/\\s+/).filter(Boolean);\n  if (parts.length === 0) return \"?\";\n  const first = parts[0].charAt(0);\n  const last = parts.length > 1 ? parts[parts.length - 1].charAt(0) : \"\";\n  return `${first}${last}`.toUpperCase();\n}\n\nconst statusColor = { online: \"#3ecf8e\", away: \"#f5a623\", offline: \"#6b6b73\" } as const;\n\nexport function SidebarFloating({\n  groups = defaultGroups,\n  active,\n  defaultActive,\n  onChange,\n  brand,\n  user = defaultUser,\n  onUserClick,\n  width = 248,\n  inset = 12,\n  rowHeight = 36,\n  color = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: SidebarFloatingProps) {\n  const navRef = React.useRef<HTMLElement>(null);\n  const pillRef = React.useRef<HTMLSpanElement>(null);\n  const itemRefs = React.useRef<Map<string, HTMLElement>>(new Map());\n  const placedRef = React.useRef(false);\n  const all = React.useMemo(() => groups.flatMap((g) => g.items), [groups]);\n  const [innerActive, setInnerActive] = React.useState(defaultActive ?? all[0]?.id ?? \"\");\n  const [focusId, setFocusId] = React.useState(\"\");\n  const current = active ?? innerActive;\n  const currentRef = React.useRef(current);\n\n  const place = React.useCallback((instant: boolean) => {\n    const pill = pillRef.current;\n    if (!pill) return;\n    const el = itemRefs.current.get(currentRef.current);\n    if (!el) {\n      pill.dataset.ready = \"false\";\n      return;\n    }\n    if (instant) pill.style.transition = \"none\";\n    pill.style.setProperty(\"--hb-sbf-ph\", `${el.offsetHeight}px`);\n    pill.style.setProperty(\"--hb-sbf-py\", `${el.offsetTop}px`);\n    pill.dataset.ready = \"true\";\n    if (instant) {\n      void pill.offsetHeight;\n      pill.style.transition = \"\";\n    }\n  }, []);\n\n  React.useEffect(() => {\n    currentRef.current = current;\n    place(!placedRef.current);\n    placedRef.current = true;\n  }, [current, groups, rowHeight, place]);\n\n  React.useEffect(() => {\n    const nav = navRef.current;\n    if (!nav) return;\n    const update = () => place(true);\n    if (typeof ResizeObserver === \"undefined\") {\n      window.addEventListener(\"resize\", update);\n      return () => window.removeEventListener(\"resize\", update);\n    }\n    const ro = new ResizeObserver(update);\n    ro.observe(nav);\n    return () => ro.disconnect();\n  }, [place]);\n\n  function select(id: string) {\n    if (active === undefined) setInnerActive(id);\n    onChange?.(id);\n  }\n\n  function handleKeyDown(e: React.KeyboardEvent<HTMLElement>) {\n    if (all.length === 0) return;\n    const ids = all.map((i) => i.id);\n    const here = ids.indexOf(focusId);\n    let next = -1;\n    if (e.key === \"ArrowDown\") next = here < 0 ? 0 : Math.min(ids.length - 1, here + 1);\n    else if (e.key === \"ArrowUp\") next = here < 0 ? ids.length - 1 : Math.max(0, here - 1);\n    else if (e.key === \"Home\") next = 0;\n    else if (e.key === \"End\") next = ids.length - 1;\n    if (next < 0) return;\n    e.preventDefault();\n    itemRefs.current.get(ids[next])?.focus();\n  }\n\n  const tabStop = all.some((i) => i.id === focusId)\n    ? focusId\n    : all.some((i) => i.id === current)\n      ? current\n      : all[0]?.id;\n\n  const vars = {\n    \"--hb-sbf-w\": `${width}px`,\n    \"--hb-sbf-inset\": `${inset}px`,\n    \"--hb-sbf-row\": `${rowHeight}px`,\n    \"--hb-sbf-accent\": color,\n    ...style,\n  } as React.CSSProperties;\n\n  const hue = user ? hashName(user.name) : 0;\n  const status = user?.status ?? \"online\";\n\n  return (\n    <aside className={`hb-sbf ${className}`} style={vars} {...rest}>\n      <style href=\"hb-sidebar-floating\" precedence=\"default\">{css}</style>\n      <div className=\"hb-sbf-panel\">\n        {brand ? <div className=\"hb-sbf-brand\">{brand}</div> : null}\n        <nav ref={navRef} className=\"hb-sbf-nav\" aria-label=\"Main\" onKeyDown={handleKeyDown}>\n          <span ref={pillRef} className=\"hb-sbf-pill\" aria-hidden=\"true\" />\n          {groups.map((group, gi) => (\n            <div key={group.label ?? gi}>\n              {group.label ? <div className=\"hb-sbf-label\">{group.label}</div> : null}\n              <ul className=\"hb-sbf-group\" role=\"list\">\n                {group.items.map((item) => {\n                  const selected = item.id === current;\n                  const setRef = (el: HTMLElement | null) => {\n                    if (el) itemRefs.current.set(item.id, el);\n                    else itemRefs.current.delete(item.id);\n                  };\n                  const content = (\n                    <>\n                      <span className=\"hb-sbf-ico\" aria-hidden=\"true\">\n                        {item.icon ?? <span className=\"hb-sbf-letter\">{item.label.charAt(0).toUpperCase()}</span>}\n                      </span>\n                      <span className=\"hb-sbf-text\">{item.label}</span>\n                      {item.badge !== undefined && item.badge !== \"\" ? <span className=\"hb-sbf-badge\">{item.badge}</span> : null}\n                    </>\n                  );\n                  const common = {\n                    className: \"hb-sbf-item\",\n                    \"aria-current\": selected ? (\"page\" as const) : undefined,\n                    tabIndex: item.id === tabStop ? 0 : -1,\n                    onFocus: () => setFocusId(item.id),\n                    onClick: () => select(item.id),\n                  };\n                  return (\n                    <li key={item.id}>\n                      {item.href ? (\n                        <a ref={setRef} href={item.href} {...common}>\n                          {content}\n                        </a>\n                      ) : (\n                        <button ref={setRef} type=\"button\" {...common}>\n                          {content}\n                        </button>\n                      )}\n                    </li>\n                  );\n                })}\n              </ul>\n            </div>\n          ))}\n        </nav>\n        {user ? (\n          <button type=\"button\" className=\"hb-sbf-user\" onClick={onUserClick} aria-label={`${user.name}, ${status}`}>\n            <span\n              className=\"hb-sbf-avatar\"\n              aria-hidden=\"true\"\n              style={{\n                background: user.color ?? `linear-gradient(135deg, hsl(${hue} 78% 62%), hsl(${(hue + 48) % 360} 70% 42%))`,\n              }}\n            >\n              {initialsOf(user.name)}\n              <span className=\"hb-sbf-dot\" data-status={status} style={{ \"--hb-sbf-status\": statusColor[status] } as React.CSSProperties} />\n            </span>\n            <span className=\"hb-sbf-who\">\n              <span className=\"hb-sbf-name\">{user.name}</span>\n              {user.role ? <span className=\"hb-sbf-role\">{user.role}</span> : null}\n            </span>\n            <svg className=\"hb-sbf-more\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M5 6.5L8 3.5l3 3M5 9.5l3 3 3-3\" />\n            </svg>\n          </button>\n        ) : null}\n      </div>\n    </aside>\n  );\n}\n"
    }
  ]
}