{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sidebar-accordion-rail",
  "type": "registry:component",
  "title": "Sidebar Accordion Rail",
  "description": "Docs-style accordion groups where only one opens at a time and its links hang from a curved branch line. A glowing bead slides to the current page while the line fills to show reading progress.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "sidebars",
    "sidebar",
    "accordion",
    "docs",
    "tree",
    "progress",
    "navigation"
  ],
  "docs": "https://hyperblur.dev/effects/sidebar-accordion-rail",
  "files": [
    {
      "path": "registry/hyperblur/sidebar-accordion-rail.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/sidebar-accordion-rail.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nconst PATHS = {\n  rocket: \"M11.5 3.5c2.6-.6 4.6-.5 5 0 .5.4.6 2.4 0 5L12 13l-5-5zM7 8l-3 .5L2.8 10l3.4 1M12 13l-.5 3-1.5 1.2-1-3.4M5.5 14.5l-2 2\",\n  book: \"M4 4.5A1.5 1.5 0 0 1 5.5 3H16v12H5.5A1.5 1.5 0 0 0 4 16.5zM4 16.5A1.5 1.5 0 0 0 5.5 18H16M7.5 6.5h5\",\n  plug: \"M7 3v4M13 3v4M5.5 7h9v2.5a4.5 4.5 0 0 1-9 0zM10 14v3.5\",\n  shield: \"M10 2.8l6 2.2v4.6c0 3.7-2.5 6.4-6 7.6-3.5-1.2-6-3.9-6-7.6V5zM7.5 10l1.8 1.8 3.4-3.6\",\n  card: \"M3 5.5h14a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1zM2 8.5h16M5 12h3\",\n  terminal: \"M3.5 4h13a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-13a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zM6 8l2.5 2L6 12M10.5 12.5h3.5\",\n} as const;\n\nexport type SidebarAccordionRailIconName = keyof typeof PATHS;\n\nexport interface SidebarAccordionRailLink {\n  id: string;\n  label: string;\n  badge?: string;\n}\n\nexport interface SidebarAccordionRailGroup {\n  id: string;\n  label: string;\n  icon?: SidebarAccordionRailIconName | React.ReactNode;\n  items: SidebarAccordionRailLink[];\n}\n\nexport interface SidebarAccordionRailProps\n  extends Omit<React.HTMLAttributes<HTMLElement>, \"onChange\" | \"children\" | \"defaultValue\"> {\n  groups?: SidebarAccordionRailGroup[];\n  active?: string;\n  defaultActive?: string;\n  onChange?: (id: string) => void;\n  openGroup?: string | null;\n  defaultOpenGroup?: string | null;\n  onOpenGroupChange?: (id: string | null) => void;\n  heading?: string;\n  caption?: string;\n  rowHeight?: number;\n  footer?: React.ReactNode;\n  accent?: string;\n}\n\nconst defaultGroups: SidebarAccordionRailGroup[] = [\n  {\n    id: \"start\",\n    label: \"Getting started\",\n    icon: \"rocket\",\n    items: [\n      { id: \"intro\", label: \"Introduction\" },\n      { id: \"quickstart\", label: \"Quickstart\" },\n      { id: \"keys\", label: \"API keys\" },\n      { id: \"sdks\", label: \"SDKs\", badge: \"New\" },\n    ],\n  },\n  {\n    id: \"guides\",\n    label: \"Guides\",\n    icon: \"book\",\n    items: [\n      { id: \"webhooks\", label: \"Webhooks\" },\n      { id: \"pagination\", label: \"Pagination\" },\n      { id: \"errors\", label: \"Error handling\" },\n    ],\n  },\n  {\n    id: \"billing\",\n    label: \"Billing\",\n    icon: \"card\",\n    items: [\n      { id: \"plans\", label: \"Plans and seats\" },\n      { id: \"invoices\", label: \"Invoices\" },\n    ],\n  },\n  {\n    id: \"security\",\n    label: \"Security\",\n    icon: \"shield\",\n    items: [\n      { id: \"sso\", label: \"Single sign-on\" },\n      { id: \"audit\", label: \"Audit log\", badge: \"Beta\" },\n    ],\n  },\n];\n\nconst css = `\n.hb-xk3 {\n  --hb-xk3-a: #2f7bff;\n  --hb-xk3-h: 30px;\n  box-sizing: border-box;\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n  height: 100%;\n  padding: 12px 10px;\n  border-right: 1px solid #1f1f1f;\n  background: #0d0d0d;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 13px;\n  line-height: 18px;\n}\n.hb-xk3 *, .hb-xk3 *::before, .hb-xk3 *::after { box-sizing: border-box; }\n.hb-xk3-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 26px; margin: 0 4px 10px 6px; }\n.hb-xk3-title { overflow: hidden; font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }\n.hb-xk3-cap { flex: none; padding: 1px 7px; border: 1px solid #2a2a2a; border-radius: 99px; background: #141414; color: #8f8f8f; font-family: var(--font-mono, ui-monospace, monospace); font-size: 10px; line-height: 16px; }\n.hb-xk3-groups { display: flex; flex: 1; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; scrollbar-width: none; }\n.hb-xk3-groups::-webkit-scrollbar { display: none; }\n.hb-xk3-head {\n  display: flex;\n  align-items: center;\n  gap: 9px;\n  width: 100%;\n  height: 32px;\n  margin: 0;\n  padding: 0 8px 0 4px;\n  border: 0;\n  border-radius: 9px;\n  background: transparent;\n  color: #a1a1a1;\n  font: inherit;\n  font-weight: 500;\n  text-align: left;\n  cursor: pointer;\n  transition: background-color .16s ease, color .16s ease;\n}\n.hb-xk3-head:hover { background: rgba(255, 255, 255, .04); color: #ededed; }\n.hb-xk3-head:focus-visible, .hb-xk3-link:focus-visible { outline: 2px solid var(--hb-xk3-a); outline-offset: -2px; }\n.hb-xk3-group[data-open=\"true\"] .hb-xk3-head { color: #fff; }\n.hb-xk3-tile {\n  display: grid;\n  flex: none;\n  place-items: center;\n  width: 24px;\n  height: 24px;\n  border: 1px solid #262626;\n  border-radius: 7px;\n  background: linear-gradient(180deg, #1a1a1a, #121212);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);\n  color: #8f8f8f;\n  transition: color .2s ease, border-color .2s ease, background .2s ease;\n}\n.hb-xk3-tile svg { width: 14px; height: 14px; }\n.hb-xk3-group[data-open=\"true\"] .hb-xk3-tile {\n  border-color: color-mix(in srgb, var(--hb-xk3-a) 45%, #262626);\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xk3-a) 28%, #151515), #121212);\n  color: color-mix(in srgb, var(--hb-xk3-a) 40%, #fff);\n}\n.hb-xk3-hl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-xk3-has { width: 6px; height: 6px; border-radius: 99px; background: var(--hb-xk3-a); box-shadow: 0 0 8px var(--hb-xk3-a); animation: hb-xk3-in .3s cubic-bezier(.22, 1, .36, 1); }\n.hb-xk3-count { color: #5f5f66; font-family: var(--font-mono, ui-monospace, monospace); font-size: 10.5px; }\n.hb-xk3-chev { flex: none; width: 14px; height: 14px; color: #5f5f66; transition: transform .35s cubic-bezier(.22, 1, .36, 1); }\n.hb-xk3-group[data-open=\"true\"] .hb-xk3-chev { transform: rotate(90deg); color: #a1a1a1; }\n.hb-xk3-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .42s cubic-bezier(.22, 1, .36, 1); }\n.hb-xk3-group[data-open=\"true\"] .hb-xk3-body { grid-template-rows: 1fr; }\n.hb-xk3-clip { min-height: 0; overflow: hidden; }\n.hb-xk3-track { position: relative; margin: 2px 0 6px; padding-left: 30px; }\n.hb-xk3-line, .hb-xk3-fill { position: absolute; top: 0; left: 16px; width: 1.5px; border-radius: 2px; }\n.hb-xk3-line { height: calc(var(--hb-xk3-n) * var(--hb-xk3-h) - var(--hb-xk3-h) / 2); background: #262626; }\n.hb-xk3-fill {\n  height: calc(var(--hb-xk3-ix) * var(--hb-xk3-h) + var(--hb-xk3-h) / 2);\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xk3-a) 10%, transparent), var(--hb-xk3-a));\n  transition: height .5s cubic-bezier(.22, 1, .36, 1), opacity .3s ease;\n}\n.hb-xk3-bead {\n  position: absolute;\n  top: 0;\n  left: 12.75px;\n  width: 8px;\n  height: 8px;\n  border: 1.5px solid #0d0d0d;\n  border-radius: 99px;\n  background: var(--hb-xk3-a);\n  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-xk3-a) 25%, transparent), 0 0 14px var(--hb-xk3-a);\n  transform: translateY(calc(var(--hb-xk3-ix) * var(--hb-xk3-h) + var(--hb-xk3-h) / 2 - 4px));\n  transition: transform .5s cubic-bezier(.34, 1.4, .5, 1), opacity .3s ease;\n}\n.hb-xk3-track[data-on=\"false\"] .hb-xk3-fill, .hb-xk3-track[data-on=\"false\"] .hb-xk3-bead { opacity: 0; }\n.hb-xk3-list { margin: 0; padding: 0; list-style: none; }\n.hb-xk3-li { position: relative; height: var(--hb-xk3-h); }\n.hb-xk3-li::before {\n  content: \"\";\n  position: absolute;\n  top: 0;\n  left: -14px;\n  width: 10px;\n  height: 50%;\n  border-bottom: 1.5px solid #262626;\n  border-left: 1.5px solid transparent;\n  border-bottom-left-radius: 7px;\n  transition: border-color .3s ease;\n}\n.hb-xk3-li[data-past=\"true\"]::before { border-bottom-color: color-mix(in srgb, var(--hb-xk3-a) 45%, #262626); }\n.hb-xk3-li[data-current=\"true\"]::before { border-bottom-color: var(--hb-xk3-a); }\n.hb-xk3-link {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  width: 100%;\n  height: 100%;\n  margin: 0;\n  padding: 0 8px;\n  border: 0;\n  border-radius: 7px;\n  background: transparent;\n  color: #8a8a90;\n  font: inherit;\n  font-size: 12.5px;\n  text-align: left;\n  white-space: nowrap;\n  cursor: pointer;\n  opacity: 0;\n  transform: translateY(-4px);\n  transition: color .16s ease, background-color .16s ease, opacity .2s ease, transform .3s cubic-bezier(.22, 1, .36, 1);\n}\n.hb-xk3-group[data-open=\"true\"] .hb-xk3-link { opacity: 1; transform: none; transition-delay: 0s, 0s, calc(var(--hb-xk3-i) * 35ms + 80ms), calc(var(--hb-xk3-i) * 35ms + 80ms); }\n.hb-xk3-link:hover { background: rgba(255, 255, 255, .04); color: #ededed; }\n.hb-xk3-li[data-past=\"true\"] .hb-xk3-link { color: #b4b4ba; }\n.hb-xk3-link[aria-current=\"page\"] { color: #fff; font-weight: 500; }\n.hb-xk3-ll { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.hb-xk3-badge { flex: none; padding: 0 6px; border-radius: 99px; background: color-mix(in srgb, var(--hb-xk3-a) 18%, transparent); color: color-mix(in srgb, var(--hb-xk3-a) 45%, #fff); font-size: 9.5px; font-weight: 600; line-height: 16px; }\n.hb-xk3-foot { flex: none; margin-top: 8px; }\n@keyframes hb-xk3-in { from { opacity: 0; transform: scale(.4); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xk3 *, .hb-xk3 *::before, .hb-xk3 *::after { transition: none !important; animation: none !important; }\n}\n`;\n\nfunction Glyph({ icon }: { icon?: SidebarAccordionRailIconName | React.ReactNode }) {\n  if (typeof icon === \"string\" || icon === undefined) {\n    const d = PATHS[(icon as SidebarAccordionRailIconName | undefined) ?? \"book\"] ?? PATHS.book;\n    return (\n      <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n        <path d={d} />\n      </svg>\n    );\n  }\n  return <>{icon}</>;\n}\n\nexport function SidebarAccordionRail({\n  groups = defaultGroups,\n  active,\n  defaultActive,\n  onChange,\n  openGroup,\n  defaultOpenGroup,\n  onOpenGroupChange,\n  heading = \"Relay API\",\n  caption = \"v4.2\",\n  rowHeight = 30,\n  footer,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  onKeyDown,\n  ...rest\n}: SidebarAccordionRailProps) {\n  const firstActive = defaultActive ?? groups[0]?.items[0]?.id ?? \"\";\n  const [inner, setInner] = React.useState(firstActive);\n  const current = active ?? inner;\n  const owner = groups.find((g) => g.items.some((i) => i.id === current))?.id ?? null;\n  const [innerOpen, setInnerOpen] = React.useState<string | null>(defaultOpenGroup !== undefined ? defaultOpenGroup : owner);\n  const opened = openGroup !== undefined ? openGroup : innerOpen;\n  const rootRef = React.useRef<HTMLElement>(null);\n  const uid = React.useId();\n\n  function setOpened(id: string | null) {\n    if (openGroup === undefined) setInnerOpen(id);\n    onOpenGroupChange?.(id);\n  }\n\n  function pick(id: string) {\n    if (active === undefined) setInner(id);\n    onChange?.(id);\n  }\n\n  function handleKeyDown(e: React.KeyboardEvent<HTMLElement>) {\n    onKeyDown?.(e);\n    if (e.defaultPrevented) return;\n    if (![\"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"].includes(e.key)) return;\n    const nodes = Array.from(rootRef.current?.querySelectorAll<HTMLElement>(\"[data-xk3-nav]\") ?? []).filter(\n      (n) => n.getAttribute(\"data-xk3-nav\") === \"head\" || n.closest('[data-open=\"true\"]'),\n    );\n    const at = nodes.indexOf(document.activeElement as HTMLElement);\n    if (at < 0) return;\n    e.preventDefault();\n    let n = at;\n    if (e.key === \"ArrowDown\") n = Math.min(nodes.length - 1, at + 1);\n    else if (e.key === \"ArrowUp\") n = Math.max(0, at - 1);\n    else if (e.key === \"Home\") n = 0;\n    else n = nodes.length - 1;\n    nodes[n]?.focus();\n  }\n\n  const vars = { \"--hb-xk3-a\": accent, \"--hb-xk3-h\": `${rowHeight}px`, ...style } as React.CSSProperties;\n\n  return (\n    <nav ref={rootRef} aria-label={heading || \"Sections\"} className={`hb-xk3 ${className}`} style={vars} onKeyDown={handleKeyDown} {...rest}>\n      <style href=\"hb-sidebar-accordion-rail\" precedence=\"default\">{css}</style>\n      {heading || caption ? (\n        <div className=\"hb-xk3-top\">\n          <span className=\"hb-xk3-title\">{heading}</span>\n          {caption ? <span className=\"hb-xk3-cap\">{caption}</span> : null}\n        </div>\n      ) : null}\n      <div className=\"hb-xk3-groups\">\n        {groups.map((group) => {\n          const isOpen = opened === group.id;\n          const idx = group.items.findIndex((i) => i.id === current);\n          const bodyId = `${uid}-${group.id}`;\n          return (\n            <div key={group.id} className=\"hb-xk3-group\" data-open={isOpen}>\n              <button\n                type=\"button\"\n                className=\"hb-xk3-head\"\n                data-xk3-nav=\"head\"\n                aria-expanded={isOpen}\n                aria-controls={bodyId}\n                onClick={() => setOpened(isOpen ? null : group.id)}\n              >\n                <span className=\"hb-xk3-tile\">\n                  <Glyph icon={group.icon} />\n                </span>\n                <span className=\"hb-xk3-hl\">{group.label}</span>\n                {!isOpen && idx >= 0 ? <span className=\"hb-xk3-has\" aria-label=\"Contains current page\" /> : null}\n                <span className=\"hb-xk3-count\" aria-hidden=\"true\">{group.items.length}</span>\n                <svg className=\"hb-xk3-chev\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  <path d=\"M6 4l4 4-4 4\" />\n                </svg>\n              </button>\n              <div id={bodyId} className=\"hb-xk3-body\" role=\"region\" aria-label={group.label} inert={!isOpen}>\n                <div className=\"hb-xk3-clip\">\n                  <div\n                    className=\"hb-xk3-track\"\n                    data-on={idx >= 0}\n                    style={{ \"--hb-xk3-n\": group.items.length, \"--hb-xk3-ix\": Math.max(0, idx) } as React.CSSProperties}\n                  >\n                    <span className=\"hb-xk3-line\" aria-hidden=\"true\" />\n                    <span className=\"hb-xk3-fill\" aria-hidden=\"true\" />\n                    <span className=\"hb-xk3-bead\" aria-hidden=\"true\" />\n                    <ul className=\"hb-xk3-list\" role=\"list\">\n                      {group.items.map((item, i) => (\n                        <li\n                          key={item.id}\n                          className=\"hb-xk3-li\"\n                          data-past={idx >= 0 && i < idx}\n                          data-current={i === idx}\n                          style={{ \"--hb-xk3-i\": i } as React.CSSProperties}\n                        >\n                          <button\n                            type=\"button\"\n                            className=\"hb-xk3-link\"\n                            data-xk3-nav=\"link\"\n                            aria-current={i === idx ? \"page\" : undefined}\n                            onClick={() => pick(item.id)}\n                          >\n                            <span className=\"hb-xk3-ll\">{item.label}</span>\n                            {item.badge ? <span className=\"hb-xk3-badge\">{item.badge}</span> : null}\n                          </button>\n                        </li>\n                      ))}\n                    </ul>\n                  </div>\n                </div>\n              </div>\n            </div>\n          );\n        })}\n      </div>\n      {footer ? <div className=\"hb-xk3-foot\">{footer}</div> : null}\n    </nav>\n  );\n}\n"
    }
  ]
}