{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sidebar-icon-labels",
  "type": "registry:component",
  "title": "Sidebar Icon Labels",
  "description": "A narrow icon rail that expands on hover or focus into a labeled sidebar floating over the content, with a sliding active indicator.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "sidebars",
    "sidebar",
    "rail",
    "icons",
    "expand",
    "hover",
    "overlay"
  ],
  "docs": "https://hyperblur.dev/effects/sidebar-icon-labels",
  "files": [
    {
      "path": "registry/hyperblur/sidebar-icon-labels.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/sidebar-icon-labels.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  calendar: \"M4.5 5h11a1 1 0 0 1 1 1v9.5a1 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  message: \"M4 4.5h12a1 1 0 0 1 1 1v7.2a1 1 0 0 1-1 1H9.5L6 17v-3.3H4a1 1 0 0 1-1-1V5.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  gear: \"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zM10 2.8v2M10 15.2v2M17.2 10h-2M4.8 10h-2M15.1 4.9l-1.4 1.4M6.3 13.7l-1.4 1.4M15.1 15.1l-1.4-1.4M6.3 6.3L4.9 4.9\",\n} as const;\n\nexport type SidebarIconLabelsIconName = keyof typeof ICONS;\n\nexport function SidebarIconLabelsIcon({ name }: { name: SidebarIconLabelsIconName }) {\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 SidebarIconLabelsItem {\n  id: string;\n  label: string;\n  icon?: SidebarIconLabelsIconName | React.ReactNode;\n  badge?: number;\n}\n\nexport interface SidebarIconLabelsProps\n  extends Omit<React.HTMLAttributes<HTMLElement>, \"onChange\" | \"children\" | \"defaultValue\"> {\n  items?: SidebarIconLabelsItem[];\n  active?: string;\n  defaultActive?: string;\n  onChange?: (id: string) => void;\n  open?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  expandOnHover?: boolean;\n  peek?: number;\n  brand?: React.ReactNode;\n  footer?: React.ReactNode;\n  collapsedWidth?: number;\n  expandedWidth?: number;\n  itemHeight?: number;\n  accent?: string;\n}\n\nconst defaultItems: SidebarIconLabelsItem[] = [\n  { id: \"home\", label: \"Home\", icon: \"home\" },\n  { id: \"calendar\", label: \"Calendar\", icon: \"calendar\" },\n  { id: \"messages\", label: \"Messages\", icon: \"message\", badge: 3 },\n  { id: \"files\", label: \"Files\", icon: \"folder\" },\n  { id: \"reports\", label: \"Reports\", icon: \"chart\" },\n  { id: \"settings\", label: \"Settings\", icon: \"gear\" },\n];\n\nconst css = `\n.hb-yc3 {\n  --hb-yc3-a: #2f7bff;\n  --hb-yc3-cw: 56px;\n  --hb-yc3-ew: 184px;\n  --hb-yc3-h: 40px;\n  --hb-yc3-gap: 4px;\n  position: relative;\n  z-index: 20;\n  flex: none;\n  box-sizing: border-box;\n  width: var(--hb-yc3-cw);\n  height: 100%;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 13px;\n  line-height: 18px;\n}\n.hb-yc3 *, .hb-yc3 *::before, .hb-yc3 *::after { box-sizing: border-box; }\n.hb-yc3-panel {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: 0;\n  display: flex;\n  flex-direction: column;\n  width: var(--hb-yc3-cw);\n  padding: 10px 8px;\n  overflow: hidden;\n  border-right: 1px solid #262626;\n  background: #0f0f0f;\n  transition: width .32s cubic-bezier(.2, .9, .2, 1), box-shadow .32s ease, background-color .32s ease;\n}\n.hb-yc3-panel[data-open=\"true\"] {\n  width: var(--hb-yc3-ew);\n  background: #121212;\n  box-shadow: 18px 0 44px rgba(0, 0, 0, .55);\n}\n.hb-yc3-brand { display: flex; flex: none; align-items: center; height: 36px; margin-bottom: 8px; padding-left: 4px; overflow: hidden; white-space: nowrap; }\n.hb-yc3-list { position: relative; display: flex; flex-direction: column; flex: none; gap: var(--hb-yc3-gap); margin: 0; padding: 0; list-style: none; }\n.hb-yc3-ind {\n  position: absolute;\n  top: 0;\n  right: 0;\n  left: 0;\n  height: var(--hb-yc3-h);\n  border-radius: 11px;\n  background: color-mix(in srgb, var(--hb-yc3-a) 16%, transparent);\n  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--hb-yc3-a) 28%, transparent);\n  pointer-events: none;\n  transform: translateY(calc(var(--hb-yc3-i, 0) * (var(--hb-yc3-h) + var(--hb-yc3-gap))));\n  transition: transform .4s cubic-bezier(.3, 1.25, .4, 1), opacity .2s ease;\n}\n.hb-yc3-ind[data-on=\"false\"] { opacity: 0; }\n.hb-yc3-ind::before {\n  content: \"\";\n  position: absolute;\n  top: 9px;\n  bottom: 9px;\n  left: -8px;\n  width: 3px;\n  border-radius: 0 3px 3px 0;\n  background: var(--hb-yc3-a);\n  box-shadow: 0 0 12px var(--hb-yc3-a);\n}\n.hb-yc3-item {\n  position: relative;\n  display: flex;\n  align-items: center;\n  width: 100%;\n  height: var(--hb-yc3-h);\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 11px;\n  background: transparent;\n  color: #8f8f8f;\n  font: inherit;\n  text-align: left;\n  white-space: nowrap;\n  cursor: pointer;\n  transition: background-color .16s ease, color .16s ease;\n}\n.hb-yc3-item:hover { background: rgba(255, 255, 255, .05); color: #ededed; }\n.hb-yc3-item[aria-current=\"true\"] { color: #ffffff; }\n.hb-yc3-item:focus-visible { outline: 2px solid var(--hb-yc3-a); outline-offset: -2px; }\n.hb-yc3-ico { position: relative; display: grid; flex: none; place-items: center; width: calc(var(--hb-yc3-cw) - 17px); height: 100%; }\n.hb-yc3-ico svg { width: 20px; height: 20px; transition: transform .2s ease, color .2s ease; }\n.hb-yc3-item[aria-current=\"true\"] .hb-yc3-ico svg { color: var(--hb-yc3-a); }\n.hb-yc3-item:active .hb-yc3-ico svg { transform: scale(.88); }\n.hb-yc3-pip {\n  position: absolute;\n  top: 9px;\n  right: 9px;\n  width: 8px;\n  height: 8px;\n  border: 2px solid #0f0f0f;\n  border-radius: 999px;\n  background: #e5484d;\n  transition: opacity .2s ease;\n}\n.hb-yc3-panel[data-open=\"true\"] .hb-yc3-pip { opacity: 0; }\n.hb-yc3-lab {\n  flex: 1;\n  min-width: 0;\n  overflow: hidden;\n  font-weight: 500;\n  text-overflow: ellipsis;\n  opacity: 0;\n  transform: translateX(-8px);\n  transition: opacity .12s ease, transform .2s ease;\n}\n.hb-yc3-panel[data-open=\"true\"] .hb-yc3-lab { opacity: 1; transform: none; transition: opacity .22s ease .08s, transform .3s cubic-bezier(.2, .9, .2, 1) .06s; }\n.hb-yc3-cnt {\n  flex: none;\n  min-width: 20px;\n  margin-right: 8px;\n  padding: 0 6px;\n  border-radius: 999px;\n  background: #e5484d;\n  color: #ffffff;\n  font-size: 11px;\n  font-weight: 700;\n  line-height: 18px;\n  text-align: center;\n  opacity: 0;\n  transition: opacity .12s ease;\n}\n.hb-yc3-panel[data-open=\"true\"] .hb-yc3-cnt { opacity: 1; transition: opacity .22s ease .1s; }\n.hb-yc3-foot { display: flex; flex: none; align-items: center; margin-top: auto; padding-left: 4px; overflow: hidden; white-space: nowrap; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-yc3-panel, .hb-yc3-ind, .hb-yc3-item, .hb-yc3-lab, .hb-yc3-cnt, .hb-yc3-pip, .hb-yc3-ico svg { transition: none !important; }\n}\n`;\n\nexport function SidebarIconLabels({\n  items = defaultItems,\n  active,\n  defaultActive,\n  onChange,\n  open,\n  onOpenChange,\n  expandOnHover = true,\n  peek = 0,\n  brand,\n  footer,\n  collapsedWidth = 56,\n  expandedWidth = 184,\n  itemHeight = 40,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  onKeyDown,\n  onPointerEnter,\n  onPointerLeave,\n  onFocus,\n  onBlur,\n  ...rest\n}: SidebarIconLabelsProps) {\n  const rootRef = React.useRef<HTMLElement>(null);\n  const seen = React.useRef(true);\n  const lastOpen = React.useRef(false);\n  const [inner, setInner] = React.useState(defaultActive ?? items[0]?.id ?? \"\");\n  const [hover, setHover] = React.useState(false);\n  const [focusIn, setFocusIn] = React.useState(false);\n  const [peeking, setPeeking] = React.useState(false);\n  const [dismissed, setDismissed] = React.useState(false);\n  const [focusId, setFocusId] = React.useState(\"\");\n  const current = active ?? inner;\n  const engaged = hover || focusIn;\n  const derived = (expandOnHover ? engaged : focusIn) || peeking;\n  const expanded = open ?? (derived && !dismissed);\n  const ids = items.map((i) => i.id);\n  const tabStop = ids.includes(focusId) ? focusId : ids.includes(current) ? current : ids[0];\n  const activeIndex = ids.indexOf(current);\n\n  React.useEffect(() => {\n    if (lastOpen.current !== expanded) {\n      lastOpen.current = expanded;\n      onOpenChange?.(expanded);\n    }\n  }, [expanded, onOpenChange]);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el || typeof IntersectionObserver === \"undefined\") return;\n    const io = new IntersectionObserver(([entry]) => {\n      seen.current = entry?.isIntersecting ?? true;\n    });\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  React.useEffect(() => {\n    if (peek <= 0 || engaged) return;\n    if (typeof window !== \"undefined\" && window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    const id = window.setInterval(() => {\n      if (seen.current) setPeeking((p) => !p);\n    }, peek);\n    return () => window.clearInterval(id);\n  }, [peek, engaged]);\n\n  function select(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 (e.key === \"Escape\") {\n      setDismissed(true);\n      setPeeking(false);\n      (document.activeElement as HTMLElement | null)?.blur();\n      return;\n    }\n    const target = e.target as HTMLElement;\n    if (!target.hasAttribute(\"data-yc3-item\")) return;\n    const list = Array.from(rootRef.current?.querySelectorAll<HTMLElement>(\"[data-yc3-item]\") ?? []);\n    const at = list.indexOf(target);\n    let next = -1;\n    if (e.key === \"ArrowDown\") next = Math.min(list.length - 1, at + 1);\n    else if (e.key === \"ArrowUp\") next = Math.max(0, at - 1);\n    else if (e.key === \"Home\") next = 0;\n    else if (e.key === \"End\") next = list.length - 1;\n    if (next >= 0) {\n      e.preventDefault();\n      list[next]?.focus();\n    }\n  }\n\n  const vars = {\n    \"--hb-yc3-a\": accent,\n    \"--hb-yc3-cw\": `${collapsedWidth}px`,\n    \"--hb-yc3-ew\": `${expandedWidth}px`,\n    \"--hb-yc3-h\": `${itemHeight}px`,\n    \"--hb-yc3-i\": Math.max(0, activeIndex),\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <nav\n      ref={rootRef}\n      className={`hb-yc3 ${className}`}\n      aria-label=\"Primary\"\n      style={vars}\n      onKeyDown={handleKeyDown}\n      onPointerEnter={(e) => {\n        onPointerEnter?.(e);\n        setHover(true);\n        setPeeking(false);\n      }}\n      onPointerLeave={(e) => {\n        onPointerLeave?.(e);\n        setHover(false);\n        setDismissed(false);\n      }}\n      onFocus={(e) => {\n        onFocus?.(e);\n        setFocusIn(true);\n        setPeeking(false);\n      }}\n      onBlur={(e) => {\n        onBlur?.(e);\n        if (!e.currentTarget.contains(e.relatedTarget as Node | null)) {\n          setFocusIn(false);\n          setDismissed(false);\n        }\n      }}\n      {...rest}\n    >\n      <style href=\"hb-sidebar-icon-labels\" precedence=\"default\">{css}</style>\n      <div className=\"hb-yc3-panel\" data-open={expanded}>\n        {brand ? <div className=\"hb-yc3-brand\">{brand}</div> : null}\n        <ul className=\"hb-yc3-list\" role=\"list\">\n          <li className=\"hb-yc3-ind\" data-on={activeIndex >= 0} aria-hidden=\"true\" />\n          {items.map((item) => (\n            <li key={item.id}>\n              <button\n                type=\"button\"\n                className=\"hb-yc3-item\"\n                data-yc3-item=\"\"\n                aria-current={item.id === current ? true : undefined}\n                tabIndex={item.id === tabStop ? 0 : -1}\n                onFocus={() => setFocusId(item.id)}\n                onClick={() => select(item.id)}\n              >\n                <span className=\"hb-yc3-ico\">\n                  {typeof item.icon === \"string\" || item.icon === undefined ? (\n                    <SidebarIconLabelsIcon name={(item.icon as SidebarIconLabelsIconName | undefined) ?? \"home\"} />\n                  ) : (\n                    item.icon\n                  )}\n                  {item.badge ? <span className=\"hb-yc3-pip\" aria-hidden=\"true\" /> : null}\n                </span>\n                <span className=\"hb-yc3-lab\">{item.label}</span>\n                {item.badge ? (\n                  <span className=\"hb-yc3-cnt\" aria-label={`${item.badge} new`}>\n                    {item.badge}\n                  </span>\n                ) : null}\n              </button>\n            </li>\n          ))}\n        </ul>\n        {footer ? <div className=\"hb-yc3-foot\">{footer}</div> : null}\n      </div>\n    </nav>\n  );\n}\n"
    }
  ]
}