{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "breadcrumbs",
  "type": "registry:component",
  "title": "Breadcrumbs",
  "description": "A breadcrumb trail that truncates long labels and folds the middle of deep paths into an ellipsis menu.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "site",
    "breadcrumbs",
    "navigation",
    "trail",
    "path",
    "docs",
    "menu"
  ],
  "docs": "https://hyperblur.dev/effects/breadcrumbs",
  "files": [
    {
      "path": "registry/hyperblur/breadcrumbs.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/breadcrumbs.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface BreadcrumbItem {\n  label: string;\n  href?: string;\n}\n\nexport interface BreadcrumbsProps extends Omit<React.HTMLAttributes<HTMLElement>, \"children\"> {\n  items?: BreadcrumbItem[];\n  separator?: \"chevron\" | \"slash\";\n  maxItems?: number;\n  maxLabelWidth?: number;\n  homeIcon?: boolean;\n  accent?: string;\n}\n\nconst defaultItems: BreadcrumbItem[] = [\n  { label: \"Home\", href: \"#\" },\n  { label: \"Docs\", href: \"#\" },\n  { label: \"Guides\", href: \"#\" },\n  { label: \"Authentication\", href: \"#\" },\n  { label: \"Single sign-on with SAML\", href: \"#\" },\n];\n\nconst css = `\n.hb-brc {\n  --hb-brc-a: #2f7bff;\n  --hb-brc-mw: 160px;\n  container: hb-brc / inline-size;\n  box-sizing: border-box;\n  width: 100%;\n  font-family: inherit;\n  font-size: 13.5px;\n}\n.hb-brc *, .hb-brc *::before, .hb-brc *::after { box-sizing: border-box; }\n.hb-brc-ol {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: center;\n  gap: 2px 0;\n  margin: 0;\n  padding: 0;\n  list-style: none;\n}\n.hb-brc-li { position: relative; display: inline-flex; align-items: center; min-width: 0; }\n.hb-brc-sep {\n  display: inline-grid;\n  place-items: center;\n  flex: none;\n  width: 22px;\n  color: #4a4a4a;\n  font-size: 13px;\n  line-height: 1;\n  user-select: none;\n}\n.hb-brc-sep svg { width: 12px; height: 12px; }\n.hb-brc-a,\n.hb-brc-cur,\n.hb-brc-more {\n  display: inline-flex;\n  align-items: center;\n  min-width: 0;\n  margin: 0;\n  padding: 4px 6px;\n  border: 0;\n  border-radius: 7px;\n  background: transparent;\n  color: #8f8f8f;\n  font: inherit;\n  line-height: 1.3;\n  text-decoration: none;\n}\n.hb-brc-t {\n  position: relative;\n  display: block;\n  max-width: var(--hb-brc-mw);\n  overflow: hidden;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n}\n.hb-brc-a { cursor: pointer; transition: color 0.2s ease; }\n.hb-brc-a .hb-brc-t::after {\n  content: \"\";\n  position: absolute;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  height: 1px;\n  background: currentColor;\n  transform: scaleX(0);\n  transform-origin: right;\n  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.2, 1);\n}\n.hb-brc-a:hover { color: #fff; }\n.hb-brc-a:hover .hb-brc-t::after { transform: scaleX(1); transform-origin: left; }\n.hb-brc-cur { color: #ededed; font-weight: 550; }\n.hb-brc-home { width: 28px; height: 28px; justify-content: center; padding: 0; }\n.hb-brc-home svg { width: 15px; height: 15px; }\n.hb-brc-more {\n  justify-content: center;\n  width: 28px;\n  height: 24px;\n  padding: 0;\n  cursor: pointer;\n  transition: background 0.2s ease, color 0.2s ease;\n}\n.hb-brc-more:hover,\n.hb-brc-more[aria-expanded=\"true\"] { background: rgba(255, 255, 255, 0.08); color: #fff; }\n.hb-brc-more svg { width: 15px; height: 15px; }\n.hb-brc-a:focus-visible,\n.hb-brc-more:focus-visible,\n.hb-brc-mi:focus-visible {\n  outline: 2px solid var(--hb-brc-a);\n  outline-offset: 1px;\n}\n.hb-brc-menu {\n  position: absolute;\n  top: calc(100% + 6px);\n  left: 0;\n  z-index: 20;\n  display: grid;\n  min-width: 170px;\n  max-width: 260px;\n  margin: 0;\n  padding: 5px;\n  list-style: none;\n  border-radius: 12px;\n  background: #141414;\n  box-shadow: inset 0 0 0 1px #2a2a2a, 0 16px 40px rgba(0, 0, 0, 0.55);\n  opacity: 0;\n  visibility: hidden;\n  pointer-events: none;\n  transform: translateY(-4px) scale(0.98);\n  transform-origin: top left;\n  transition: opacity 0.15s ease, transform 0.22s cubic-bezier(0.2, 0.9, 0.2, 1), visibility 0s linear 0.22s;\n}\n.hb-brc-menu[data-open=\"true\"] {\n  opacity: 1;\n  visibility: visible;\n  pointer-events: auto;\n  transform: none;\n  transition: opacity 0.15s ease, transform 0.22s cubic-bezier(0.2, 0.9, 0.2, 1), visibility 0s;\n}\n.hb-brc-mi {\n  display: block;\n  padding: 8px 10px;\n  overflow: hidden;\n  border-radius: 8px;\n  color: #cfcfcf;\n  text-decoration: none;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n  transition: background 0.15s ease, color 0.15s ease;\n}\n.hb-brc-mi:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }\n@container hb-brc (max-width: 359px) {\n  .hb-brc-t { max-width: min(var(--hb-brc-mw), 96px); }\n  .hb-brc-sep { width: 18px; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-brc-a, .hb-brc-more, .hb-brc-menu, .hb-brc-mi, .hb-brc-a .hb-brc-t::after { transition: none; }\n}\n`;\n\nfunction Separator({ kind }: { kind: \"chevron\" | \"slash\" }) {\n  return (\n    <span className=\"hb-brc-sep\" aria-hidden=\"true\">\n      {kind === \"slash\" ? (\n        \"/\"\n      ) : (\n        <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n          <path d=\"m4.5 2.5 3.5 3.5-3.5 3.5\" />\n        </svg>\n      )}\n    </span>\n  );\n}\n\nexport function Breadcrumbs({\n  items = defaultItems,\n  separator = \"chevron\",\n  maxItems = 4,\n  maxLabelWidth = 160,\n  homeIcon = false,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  onKeyDown,\n  onBlur,\n  ...rest\n}: BreadcrumbsProps) {\n  const uid = React.useId();\n  const rootRef = React.useRef<HTMLElement>(null);\n  const moreRef = React.useRef<HTMLButtonElement>(null);\n  const menuRef = React.useRef<HTMLUListElement>(null);\n  const [open, setOpen] = React.useState(false);\n  const focusFirst = React.useRef(false);\n\n  const limit = Math.max(2, maxItems);\n  const collapsed = items.length > limit;\n  const tail = Math.max(1, limit - 2);\n  const hidden = collapsed ? items.slice(1, items.length - tail) : [];\n  const shown: (BreadcrumbItem | \"more\")[] = collapsed\n    ? [items[0], \"more\", ...items.slice(items.length - tail)]\n    : items;\n\n  React.useEffect(() => {\n    if (!open) return;\n    function onDown(e: PointerEvent) {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false);\n    }\n    document.addEventListener(\"pointerdown\", onDown);\n    return () => document.removeEventListener(\"pointerdown\", onDown);\n  }, [open]);\n\n  React.useEffect(() => {\n    if (open && focusFirst.current) {\n      focusFirst.current = false;\n      menuRef.current?.querySelector<HTMLElement>(\"a\")?.focus();\n    }\n  }, [open]);\n\n  function handleKeyDown(e: React.KeyboardEvent<HTMLElement>) {\n    onKeyDown?.(e);\n    if (e.defaultPrevented || !open) return;\n    if (e.key === \"Escape\") {\n      e.preventDefault();\n      setOpen(false);\n      moreRef.current?.focus();\n    }\n  }\n\n  function handleBlur(e: React.FocusEvent<HTMLElement>) {\n    onBlur?.(e);\n    const next = e.relatedTarget as Node | null;\n    if (open && next && !e.currentTarget.contains(next)) setOpen(false);\n  }\n\n  function handleMenuKey(e: React.KeyboardEvent<HTMLUListElement>) {\n    const links = Array.from(e.currentTarget.querySelectorAll<HTMLElement>(\"a\"));\n    const i = links.indexOf(e.target as HTMLElement);\n    if (i < 0) return;\n    let next = -1;\n    if (e.key === \"ArrowDown\") next = (i + 1) % links.length;\n    else if (e.key === \"ArrowUp\") next = (i - 1 + links.length) % links.length;\n    else if (e.key === \"Home\") next = 0;\n    else if (e.key === \"End\") next = links.length - 1;\n    if (next < 0) return;\n    e.preventDefault();\n    links[next].focus();\n  }\n\n  const rootStyle = {\n    \"--hb-brc-a\": accent,\n    \"--hb-brc-mw\": `${maxLabelWidth}px`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <nav\n      ref={rootRef}\n      aria-label=\"Breadcrumb\"\n      className={`hb-brc ${className}`}\n      style={rootStyle}\n      onKeyDown={handleKeyDown}\n      onBlur={handleBlur}\n      {...rest}\n    >\n      <style href=\"hb-breadcrumbs\" precedence=\"default\">{css}</style>\n      <ol className=\"hb-brc-ol\">\n        {shown.map((item, i) => {\n          const last = i === shown.length - 1;\n          if (item === \"more\") {\n            return (\n              <li className=\"hb-brc-li\" key=\"more\">\n                <button\n                  ref={moreRef}\n                  type=\"button\"\n                  className=\"hb-brc-more\"\n                  aria-label={`Show ${hidden.length} more`}\n                  aria-expanded={open}\n                  aria-controls={`${uid}-menu`}\n                  onClick={() => setOpen((v) => !v)}\n                  onKeyDown={(e) => {\n                    if (e.key === \"ArrowDown\") {\n                      e.preventDefault();\n                      if (open) menuRef.current?.querySelector<HTMLElement>(\"a\")?.focus();\n                      else {\n                        focusFirst.current = true;\n                        setOpen(true);\n                      }\n                    }\n                  }}\n                >\n                  <svg viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden=\"true\">\n                    <circle cx=\"3.5\" cy=\"8\" r=\"1.25\" />\n                    <circle cx=\"8\" cy=\"8\" r=\"1.25\" />\n                    <circle cx=\"12.5\" cy=\"8\" r=\"1.25\" />\n                  </svg>\n                </button>\n                <ul\n                  ref={menuRef}\n                  id={`${uid}-menu`}\n                  className=\"hb-brc-menu\"\n                  data-open={open ? \"true\" : \"false\"}\n                  onKeyDown={handleMenuKey}\n                >\n                  {hidden.map((h) => (\n                    <li key={h.label}>\n                      <a className=\"hb-brc-mi\" href={h.href ?? \"#\"} title={h.label} onClick={() => setOpen(false)}>\n                        {h.label}\n                      </a>\n                    </li>\n                  ))}\n                </ul>\n                <Separator kind={separator} />\n              </li>\n            );\n          }\n          const isHome = homeIcon && item === items[0];\n          return (\n            <li className=\"hb-brc-li\" key={`${i}-${item.label}`}>\n              {last ? (\n                <span className=\"hb-brc-cur\" aria-current=\"page\" title={item.label}>\n                  <span className=\"hb-brc-t\">{item.label}</span>\n                </span>\n              ) : isHome ? (\n                <a className=\"hb-brc-a hb-brc-home\" href={item.href ?? \"#\"} aria-label={item.label}>\n                  <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <path d=\"M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6h-6v6H4a1 1 0 0 1-1-1v-9.5z\" />\n                  </svg>\n                </a>\n              ) : (\n                <a className=\"hb-brc-a\" href={item.href ?? \"#\"} title={item.label}>\n                  <span className=\"hb-brc-t\">{item.label}</span>\n                </a>\n              )}\n              {!last && <Separator kind={separator} />}\n            </li>\n          );\n        })}\n      </ol>\n    </nav>\n  );\n}\n"
    }
  ]
}