{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "breadcrumb",
  "title": "Breadcrumb",
  "description": "Slash, chevron, dot, pill, arrow-step and underline trails with four current-page styles, tones, sizes, a staggered fade or sliding hover underline, and long trails that collapse into a keyboard-friendly menu.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/locale.json"
  ],
  "files": [
    {
      "path": "registry/components/core/breadcrumb.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\nimport { cn } from \"@/lib/utils\"\nimport { useLabels } from \"@/lib/goodui-locale\"\nimport { GooduiTokens, ease as easing } from \"@/lib/goodui-motion\"\n\n/*\n * Breadcrumb with independent layers:\n *   variant    slash, chevron, dot, pill (every crumb a pill), arrow-steps (chevron segments), underline\n *   current    how the last crumb reads: bold, muted, tone, badge\n *   animation  none, fade (staggered entrance), underline (hover underline that slides in)\n *   tone, size, and maxItems: long trails collapse their middle into an accessible \"…\" menu.\n * Pass `linkAs={Link}` to render your router's link (next/link, react-router…).\n */\n\nexport type BreadcrumbVariant = \"slash\" | \"chevron\" | \"dot\" | \"pill\" | \"arrow-steps\" | \"underline\"\nexport type BreadcrumbTone = \"primary\" | \"neutral\" | \"success\" | \"warning\" | \"danger\" | \"info\"\nexport type BreadcrumbCurrent = \"bold\" | \"muted\" | \"tone\" | \"badge\"\nexport type BreadcrumbAnimation = \"none\" | \"fade\" | \"underline\"\nexport type BreadcrumbSize = \"sm\" | \"md\" | \"lg\"\n\nexport type BreadcrumbItem = {\n  label: React.ReactNode\n  /** Link target; rendered through linkAs. Ignored on the last (current) item. */\n  href?: string\n  /** Icon before the label. */\n  icon?: React.ReactNode\n  /** Click handler; an item with onClick and no href renders as a <button>. */\n  onClick?: (e: React.MouseEvent) => void\n}\n\nexport type BreadcrumbLabels = { showMore: (count: number) => string; hiddenPages: string }\nconst DEFAULT_LABELS: BreadcrumbLabels = { showMore: (count) => `Show ${count} more`, hiddenPages: \"Hidden pages\" }\n\nexport type BreadcrumbProps = Omit<React.ComponentProps<\"nav\">, \"children\"> & {\n  /** The trail, root first. The last item is the current page. */\n  items: BreadcrumbItem[]\n  /** Separator and crumb style: slash, chevron (default), dot, pill, arrow-steps or underline. */\n  variant?: BreadcrumbVariant\n  /** Color of the current item (tone and badge styles), pill and arrow-step highlights, and focus rings. */\n  tone?: BreadcrumbTone\n  size?: BreadcrumbSize\n  /** Style of the current (last) item. */\n  current?: BreadcrumbCurrent\n  /** fade staggers the crumbs in on mount; underline grows an underline under hovered links. */\n  animation?: BreadcrumbAnimation\n  /** Collapse the middle into a \"…\" menu when there are more items than this. 0 never collapses. Numeric strings work too. */\n  maxItems?: number | string\n  /** Items kept before the \"…\" when collapsed. */\n  itemsBeforeCollapse?: number\n  /** Items kept after the \"…\" when collapsed (including the current page). */\n  itemsAfterCollapse?: number\n  /** Custom separator, replaces the variant's. */\n  separator?: React.ReactNode\n  /** Link component, e.g. next/link. Receives href, className and children. */\n  linkAs?: React.ElementType\n  /** Text for built-in controls and screen readers; pass translations here. */\n  labels?: Partial<BreadcrumbLabels>\n}\n\nconst tones = (c: string) => `\n.${c}{--pc-c:var(--primary);--pc-fg:var(--primary-foreground)}\n.${c}[data-tone=neutral]{--pc-c:var(--foreground);--pc-fg:var(--background)}\n.${c}[data-tone=success]{--pc-c:oklch(0.53 0.13 155);--pc-fg:#fff}\n.${c}[data-tone=warning]{--pc-c:oklch(0.75 0.16 70);--pc-fg:oklch(0.25 0.05 70)}\n.${c}[data-tone=danger]{--pc-c:oklch(0.56 0.21 27);--pc-fg:#fff}\n.${c}[data-tone=info]{--pc-c:oklch(0.55 0.17 250);--pc-fg:#fff}\n.dark .${c}[data-tone=success]{--pc-c:oklch(0.7 0.16 155);--pc-fg:oklch(0.2 0.05 155)}\n.dark .${c}[data-tone=danger]{--pc-c:oklch(0.68 0.2 25);--pc-fg:oklch(0.2 0.05 25)}\n.dark .${c}[data-tone=info]{--pc-c:oklch(0.7 0.15 245);--pc-fg:oklch(0.2 0.05 245)}\n.${c}{--pc-tint:color-mix(in oklab,var(--pc-c) 14%,transparent);--pc-ink:color-mix(in oklab,var(--pc-c) 82%,var(--foreground))}\n.${c}[data-tone=warning]{--pc-ink:color-mix(in oklab,var(--pc-c) 62%,var(--foreground))}\n`\n\nconst N = \".pc-breadcrumb\"\nconst C = \".pc-breadcrumb-crumb\"\nconst CUR = `${C}[aria-current=page]`\nconst CSS = `${tones(\"pc-breadcrumb\")}\n${C}{color:var(--muted-foreground);text-decoration:none;-webkit-tap-highlight-color:transparent}\na${C}:hover,button${C}:hover{color:var(--foreground)}\n.pc-breadcrumb-sep{color:color-mix(in oklab,var(--foreground) 32%,transparent)}\n${N}[data-current=bold] ${CUR}{color:var(--foreground);font-weight:600}\n${N}[data-current=muted] ${CUR}{color:var(--muted-foreground)}\n${N}[data-current=tone] ${CUR}{color:var(--pc-ink);font-weight:500}\n${N}[data-current=badge] ${CUR}{color:var(--pc-ink);background:var(--pc-tint);font-weight:500}\n\n${N}:is([data-variant=pill],[data-variant=arrow-steps]) ${C}{color:color-mix(in oklab,var(--muted-foreground) 78%,var(--foreground))}\n${N}[data-variant=pill] ${C}{background:color-mix(in oklab,var(--foreground) 6%,transparent)}\n${N}[data-variant=pill] a${C}:hover,${N}[data-variant=pill] button${C}:hover{background:var(--pc-tint);color:var(--pc-ink)}\n${N}[data-variant=pill]:is([data-current=tone],[data-current=badge]) ${CUR}{background:var(--pc-c);color:var(--pc-fg)}\n${N}[data-variant=pill][data-current=bold] ${CUR}{background:color-mix(in oklab,var(--foreground) 12%,transparent)}\n${N}[data-variant=pill][data-current=muted] ${CUR}{background:transparent}\n\n${N}[data-variant=arrow-steps] ${C}{--a:10px;background:color-mix(in oklab,var(--foreground) 7%,transparent);clip-path:polygon(0 0,calc(100% - var(--a)) 0,100% 50%,calc(100% - var(--a)) 100%,0 100%,var(--a) 50%)}\n${N}[data-variant=arrow-steps] li:first-child>${C}{clip-path:polygon(0 0,calc(100% - var(--a)) 0,100% 50%,calc(100% - var(--a)) 100%,0 100%)}\n${N}[data-variant=arrow-steps] ${C}:dir(rtl){clip-path:polygon(var(--a) 0,100% 0,calc(100% - var(--a)) 50%,100% 100%,var(--a) 100%,0 50%)}\n${N}[data-variant=arrow-steps] li:first-child>${C}:dir(rtl){clip-path:polygon(var(--a) 0,100% 0,100% 100%,var(--a) 100%,0 50%)}\n${N}[data-variant=arrow-steps] a${C}:hover,${N}[data-variant=arrow-steps] button${C}:hover{background:var(--pc-tint);color:var(--pc-ink)}\n${N}[data-variant=arrow-steps] ${CUR}{background:var(--pc-c);color:var(--pc-fg)}\n${N}[data-variant=arrow-steps][data-current=muted] ${CUR}{background:color-mix(in oklab,var(--foreground) 14%,transparent);color:var(--foreground)}\n${N}[data-variant=arrow-steps][data-current=bold] ${CUR}{font-weight:600}\n\n${N}[data-variant=underline] ${C}>[data-slot=label]{padding-bottom:7px;margin-bottom:-5px}\n${N}[data-variant=underline] :is(a,button)${C}>[data-slot=label]{text-decoration:underline;text-decoration-color:color-mix(in oklab,var(--foreground) 30%,transparent);text-underline-offset:4px;text-decoration-thickness:1px}\n${N}[data-variant=underline] :is(a,button)${C}:hover>[data-slot=label]{text-decoration-color:currentColor}\n${N}[data-variant=underline] ${CUR}>[data-slot=label]{text-decoration:underline;text-decoration-color:var(--pc-c);text-underline-offset:4px;text-decoration-thickness:2px}\n\n${N}[data-anim=underline]:not([data-variant=underline]) :is(a,button)${C}>[data-slot=label]{background:linear-gradient(currentColor,currentColor) 0 100%/0 1.5px no-repeat;transition:background-size .28s var(--pc-ease-out)}\n${N}[data-anim=underline]:not([data-variant=underline]) :is(a,button)${C}:hover>[data-slot=label]{background-size:100% 1.5px}\n${N}[data-anim=underline]:not([data-variant=underline]) :is(a,button)${C}:dir(rtl)>[data-slot=label]{background-position:100% 100%}\n${N}[data-anim=fade] .pc-breadcrumb-li{--pc-x:-6px;animation:pc-breadcrumb-in .4s var(--pc-ease-out) both;animation-delay:calc(var(--i) * 55ms)}\n${N}[data-anim=fade] .pc-breadcrumb-li:dir(rtl){--pc-x:6px}\n@keyframes pc-breadcrumb-in{from{opacity:0;transform:translateX(var(--pc-x))}}\n${N}[data-anim]:not([data-anim=none]) ${C}{transition:color .15s,background-color .15s}\n.pc-breadcrumb-menu-item{color:var(--foreground)}\n.pc-breadcrumb-menu-item:hover,.pc-breadcrumb-menu-item:focus-visible{background:var(--pc-tint);color:var(--pc-ink);outline:none}\n@media (prefers-reduced-motion:reduce){\n  ${N} *{animation:none!important;transition:none!important}\n}\n`\n\nconst SIZE: Record<BreadcrumbSize, { text: string; gap: string; pad: string; arrow: string; icon: string }> = {\n  sm: { text: \"text-xs\", gap: \"gap-1.5\", pad: \"h-6 px-2\", arrow: \"h-7 ps-4 pe-5\", icon: \"[&_svg]:size-3.5\" },\n  md: { text: \"text-sm\", gap: \"gap-2\", pad: \"h-7 px-2.5\", arrow: \"h-8 ps-5 pe-6\", icon: \"[&_svg]:size-4\" },\n  lg: { text: \"text-base\", gap: \"gap-2.5\", pad: \"h-9 px-3\", arrow: \"h-10 ps-6 pe-7\", icon: \"[&_svg]:size-[18px]\" },\n}\n\nfunction Chevron() {\n  return (\n    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className=\"rtl:-scale-x-100\">\n      <path d=\"m9 18 6-6-6-6\" />\n    </svg>\n  )\n}\n\nfunction Sep({ variant, custom }: { variant: BreadcrumbVariant; custom?: React.ReactNode }) {\n  if (custom !== undefined) return <>{custom}</>\n  if (variant === \"slash\" || variant === \"underline\") return <span className=\"px-0.5 select-none\">/</span>\n  if (variant === \"dot\") return <span className=\"block size-1 rounded-full bg-current\" />\n  return <Chevron />\n}\n\ntype Entry = { kind: \"item\"; item: BreadcrumbItem; index: number } | { kind: \"more\"; hidden: BreadcrumbItem[] }\n\nexport function Breadcrumb({\n  items,\n  variant = \"chevron\",\n  tone = \"primary\",\n  size = \"md\",\n  current = \"bold\",\n  animation = \"none\",\n  maxItems = 0,\n  itemsBeforeCollapse = 1,\n  itemsAfterCollapse = 2,\n  separator,\n  linkAs,\n  className,\n  \"aria-label\": ariaLabel = \"Breadcrumb\",\n  labels,\n  ...props\n}: BreadcrumbProps) {\n  const l = useLabels(\"breadcrumb\", DEFAULT_LABELS, labels)\n  const s = SIZE[size]\n  const max = Number(maxItems) || 0\n  const collapse = max > 0 && items.length > max && items.length > itemsBeforeCollapse + itemsAfterCollapse\n  const entries: Entry[] = collapse\n    ? [\n        ...items.slice(0, itemsBeforeCollapse).map((item, index) => ({ kind: \"item\" as const, item, index })),\n        { kind: \"more\" as const, hidden: items.slice(itemsBeforeCollapse, items.length - itemsAfterCollapse) },\n        ...items.slice(items.length - itemsAfterCollapse).map((item, i) => ({ kind: \"item\" as const, item, index: items.length - itemsAfterCollapse + i })),\n      ]\n    : items.map((item, index) => ({ kind: \"item\" as const, item, index }))\n\n  const arrows = variant === \"arrow-steps\"\n  const boxed = variant === \"pill\" || current === \"badge\"\n  const crumbClass = (isCurrent: boolean) =>\n    cn(\n      \"pc-breadcrumb-crumb inline-flex max-w-[16rem] items-center gap-1.5 whitespace-nowrap outline-none\",\n      \"focus-visible:ring-3 focus-visible:ring-[color-mix(in_oklab,var(--pc-c)_40%,transparent)]\",\n      \"[&_svg]:shrink-0\",\n      s.icon,\n      arrows ? cn(s.arrow, \"-me-[7px] rounded-none focus-visible:ring-inset\") : variant === \"pill\" || (isCurrent && boxed) ? cn(s.pad, \"rounded-full\") : \"rounded-sm\",\n    )\n\n  const Link = linkAs ?? \"a\"\n\n  return (\n    <>\n      <GooduiTokens />\n      <style href=\"pc-breadcrumb\" precedence=\"default\">\n        {CSS}\n      </style>\n      <nav\n        aria-label={ariaLabel}\n        data-slot=\"breadcrumb\"\n        data-variant={variant}\n        data-tone={tone}\n        data-current={current}\n        data-anim={animation}\n        className={cn(\"pc-breadcrumb min-w-0\", className)}\n        {...props}\n      >\n        <ol className={cn(\"flex flex-wrap items-center\", arrows ? \"gap-y-1.5\" : cn(s.gap, \"gap-y-1.5\"), s.text)}>\n          {entries.map((e, i) => {\n            const last = i === entries.length - 1\n            const key = e.kind === \"more\" ? \"more\" : `${e.index}`\n            const style = { \"--i\": i } as React.CSSProperties\n            const sep =\n              !last && !arrows ? (\n                <li key={`${key}-sep`} role=\"presentation\" aria-hidden=\"true\" className={cn(\"pc-breadcrumb-sep pc-breadcrumb-li inline-flex items-center\", s.icon, \"[&_svg]:opacity-90\")} style={style}>\n                  <Sep variant={variant} custom={separator} />\n                </li>\n              ) : null\n            if (e.kind === \"more\") {\n              return (\n                <React.Fragment key={key}>\n                  <li className=\"pc-breadcrumb-li relative inline-flex\" style={style}>\n                    <More hidden={e.hidden} className={crumbClass(false)} Link={Link} arrows={arrows} labels={l} />\n                  </li>\n                  {sep}\n                </React.Fragment>\n              )\n            }\n            const { item } = e\n            const isCurrent = e.index === items.length - 1\n            const inner = (\n              <>\n                {item.icon}\n                <span data-slot=\"label\" className=\"truncate py-0.5\">\n                  {item.label}\n                </span>\n              </>\n            )\n            return (\n              <React.Fragment key={key}>\n                <li className=\"pc-breadcrumb-li inline-flex min-w-0 items-center\" style={style}>\n                  {isCurrent ? (\n                    <span aria-current=\"page\" className={crumbClass(true)}>\n                      {inner}\n                    </span>\n                  ) : item.href ? (\n                    <Link href={item.href} onClick={item.onClick} className={crumbClass(false)}>\n                      {inner}\n                    </Link>\n                  ) : item.onClick ? (\n                    <button type=\"button\" onClick={item.onClick} className={`pc-press ${crumbClass(false)}`}>\n                      {inner}\n                    </button>\n                  ) : (\n                    <span className={crumbClass(false)}>{inner}</span>\n                  )}\n                </li>\n                {sep}\n              </React.Fragment>\n            )\n          })}\n        </ol>\n      </nav>\n    </>\n  )\n}\n\nfunction More({ hidden, className, Link, arrows, labels }: { hidden: BreadcrumbItem[]; className: string; Link: React.ElementType; arrows: boolean; labels: BreadcrumbLabels }) {\n  const [open, setOpen] = React.useState(false)\n  const reduce = useReducedMotion() ?? false\n  const id = React.useId()\n  const btn = React.useRef<HTMLButtonElement>(null)\n  const menu = React.useRef<HTMLDivElement>(null)\n\n  React.useEffect(() => {\n    if (!open) return\n    menu.current?.querySelector<HTMLElement>(\"[role=menuitem]\")?.focus()\n    const onDown = (e: PointerEvent) => {\n      if (!menu.current?.contains(e.target as Node) && !btn.current?.contains(e.target as Node)) setOpen(false)\n    }\n    document.addEventListener(\"pointerdown\", onDown)\n    return () => document.removeEventListener(\"pointerdown\", onDown)\n  }, [open])\n\n  const onMenuKey = (e: React.KeyboardEvent) => {\n    const els = Array.from(menu.current?.querySelectorAll<HTMLElement>(\"[role=menuitem]\") ?? [])\n    const i = els.indexOf(document.activeElement as HTMLElement)\n    if (e.key === \"Escape\") {\n      e.preventDefault()\n      setOpen(false)\n      btn.current?.focus()\n    } else if (e.key === \"ArrowDown\") {\n      e.preventDefault()\n      els[(i + 1) % els.length]?.focus()\n    } else if (e.key === \"ArrowUp\") {\n      e.preventDefault()\n      els[(i - 1 + els.length) % els.length]?.focus()\n    } else if (e.key === \"Home\") {\n      e.preventDefault()\n      els[0]?.focus()\n    } else if (e.key === \"End\") {\n      e.preventDefault()\n      els[els.length - 1]?.focus()\n    } else if (e.key === \"Tab\") setOpen(false)\n  }\n\n  return (\n    <>\n      <button\n        ref={btn}\n        type=\"button\"\n        aria-label={labels.showMore(hidden.length)}\n        aria-haspopup=\"menu\"\n        aria-expanded={open}\n        aria-controls={open ? id : undefined}\n        onClick={() => setOpen((o) => !o)}\n        onKeyDown={(e) => {\n          if (e.key === \"ArrowDown\" && !open) {\n            e.preventDefault()\n            setOpen(true)\n          }\n        }}\n        className={cn(\"pc-press\", className, !arrows && \"px-1\", \"tracking-widest\")}\n      >\n        <span data-slot=\"label\">…</span>\n      </button>\n      <AnimatePresence>\n        {open && (\n          <motion.div\n            ref={menu}\n            id={id}\n            role=\"menu\"\n            aria-label={labels.hiddenPages}\n            onKeyDown={onMenuKey}\n            initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4, scale: 0.97 }}\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4, scale: 0.97 }}\n            transition={{ duration: reduce ? 0 : 0.16, ease: easing.out }}\n            className=\"absolute start-0 top-full z-50 origin-top-left rtl:origin-top-right mt-1.5 flex min-w-44 flex-col rounded-lg border bg-popover p-1 text-sm text-popover-foreground shadow-[var(--pc-e2)]\"\n          >\n            {hidden.map((item, i) => {\n              const cls = \"pc-breadcrumb-menu-item flex items-center gap-2 rounded-md px-2 py-1.5 text-start whitespace-nowrap [&_svg]:size-4 [&_svg]:text-muted-foreground\"\n              const close = (e: React.MouseEvent) => {\n                item.onClick?.(e)\n                setOpen(false)\n              }\n              return item.href ? (\n                <Link key={i} role=\"menuitem\" tabIndex={-1} href={item.href} onClick={close} className={cls}>\n                  {item.icon}\n                  {item.label}\n                </Link>\n              ) : (\n                <button key={i} type=\"button\" role=\"menuitem\" tabIndex={-1} onClick={close} className={`pc-press ${cls}`}>\n                  {item.icon}\n                  {item.label}\n                </button>\n              )\n            })}\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/breadcrumb.tsx"
    }
  ],
  "categories": [
    "components",
    "core"
  ],
  "type": "registry:component"
}