{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "breadcrumb",
  "title": "Breadcrumb",
  "description": "Trail of links to the current page, with separators and an ellipsis.",
  "dependencies": [
    "class-variance-authority@^0.7.1",
    "lucide-react@^1.27.0",
    "radix-ui@^1.6.7"
  ],
  "registryDependencies": [
    "@pestoui/style",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/ui/breadcrumb.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva } from \"class-variance-authority\"\nimport { Slot } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\nimport {\n  ArrowRightIcon,\n  ChevronRightIcon,\n  MoreHorizontalIcon,\n  SlashIcon,\n} from \"lucide-react\"\n\n/* A breadcrumb is a line of prose you read far more often than you click, so\n * the whole family is tuned to stay quiet: colour-only hover, no fills, no\n * movement inside the text line, and every separator kept silent to screen\n * readers.\n *\n * Two things travel by context rather than by prop drilling — the size and the\n * separator glyph. Both are trail-wide decisions: a trail with a chevron at one\n * joint and a slash at the next is a bug, not a feature, and every call site\n * hand-passing the same glyph as children is one more chance to drift on size,\n * colour and aria. The root sets them once; every part reads them.\n *\n * The root emits data-size for descendants and consumers, and never reads it\n * back to style itself.\n *\n * Everything added here is inert until it is asked for. The icon selectors only\n * match when a crumb actually contains an svg, and the focus treatment only\n * resolves under :focus-visible — so a text-only trail at the default size\n * computes exactly what it computed before any of this existed. */\n\ntype BreadcrumbSize = \"default\" | \"sm\"\n\ntype BreadcrumbSeparatorKind = \"chevron\" | \"slash\" | \"arrow\" | \"dot\" | \"line\"\n\ntype BreadcrumbContextValue = {\n  size: BreadcrumbSize\n  separator: BreadcrumbSeparatorKind\n}\n\n/* Defaulted rather than nullable: the parts are copy-pasteable on their own and\n * should not explode when one is lifted out of its trail. */\nconst BreadcrumbContext = React.createContext<BreadcrumbContextValue>({\n  size: \"default\",\n  separator: \"chevron\",\n})\n\nfunction useBreadcrumb() {\n  return React.useContext(BreadcrumbContext)\n}\n\n/* Shared by the link and the page so an icon crumb behaves the same whether or\n * not it happens to be the current one. A crumb only becomes a flex line when\n * it actually holds an icon — a plain text crumb stays inline, which is what\n * lets it wrap mid-trail the way prose does. */\nconst crumbIconLayout =\n  \"has-[>svg]:inline-flex has-[>svg]:items-center has-[>svg]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0\"\n\nconst crumbIconSize = {\n  default: \"[&_svg:not([class*='size-'])]:size-4\",\n  sm: \"[&_svg:not([class*='size-'])]:size-3.5\",\n} as const\n\nconst breadcrumbListVariants = cva(\n  \"flex flex-wrap items-center wrap-break-word text-muted-foreground\",\n  {\n    variants: {\n      size: {\n        default: \"gap-2 text-body\",\n        sm: \"gap-1.5 text-sm\",\n      },\n    },\n    defaultVariants: {\n      size: \"default\",\n    },\n  }\n)\n\nconst breadcrumbLinkVariants = cva(\n  [\n    /* Colour, nothing else. A breadcrumb is a line of prose you read more\n       often than you click, and anything that moves in a line of text\n       pulls the eye off the words. */\n    \"transition-colors duration-fast ease-out-expo hover:text-foreground\",\n    /* The whole focus treatment sits behind :focus-visible, including the\n       radius and the outline reset. A bare link has no resting box to shape,\n       so shaping one at rest would be inventing it. */\n    \"focus-visible:rounded-sm focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50\",\n    crumbIconLayout,\n  ].join(\" \"),\n  {\n    variants: {\n      size: {\n        default: crumbIconSize.default,\n        sm: crumbIconSize.sm,\n      },\n    },\n    defaultVariants: {\n      size: \"default\",\n    },\n  }\n)\n\nconst breadcrumbPageVariants = cva(\n  `font-medium text-foreground ${crumbIconLayout}`,\n  {\n    variants: {\n      size: {\n        default: crumbIconSize.default,\n        sm: crumbIconSize.sm,\n      },\n    },\n    defaultVariants: {\n      size: \"default\",\n    },\n  }\n)\n\n/* dot and line are drawn spans rather than glyphs, so the row needs a flex\n * context to centre them against the text. The three icon kinds keep the\n * original block li — an svg is already centred by the list. */\nconst breadcrumbSeparatorVariants = cva(\"\", {\n  variants: {\n    variant: {\n      chevron: \"\",\n      slash: \"\",\n      arrow: \"\",\n      dot: \"flex items-center\",\n      line: \"flex items-center\",\n    },\n    size: {\n      default: \"[&>svg]:size-3.5\",\n      sm: \"[&>svg]:size-3\",\n    },\n  },\n  defaultVariants: {\n    variant: \"chevron\",\n    size: \"default\",\n  },\n})\n\nconst breadcrumbEllipsisVariants = cva(\"flex items-center justify-center\", {\n  variants: {\n    size: {\n      default: \"size-5 [&>svg]:size-4\",\n      sm: \"size-4.5 [&>svg]:size-3.5\",\n    },\n    /* Only the trigger form gets a resting box, a hover and a ring — the\n       decorative form is a glyph in a sentence and owns none of that. A square\n       target is one of the few places a full round cannot collapse a shape.\n\n       It is also the only crumb that answers a press, and only with its glyph.\n       The box is a menu anchor — a panel positioned against a squeezed box\n       opens a pixel off — so it never scales; the dots inside it squeeze on\n       the press spring instead, which leaves the line of text where it is. No\n       lean: the menu opens on pointerdown, so there is no \"about to\" to point\n       at.\n\n       That pointerdown is default-prevented by the DropdownMenu trigger, and\n       `:active` still reaches the box — but only when it is not already\n       focused. Measured in headed and headless Chromium with the mouse held,\n       inside a real DropdownMenu: an unfocused trigger matches `:active` on\n       every frame and the dots reach 0.9; once the menu has closed and handed\n       focus back, the next press never matches, because opening moves focus\n       into the menu and Chromium drops `:active` from an element that loses\n       focus mid-press. Touch and pen were not measured. */\n    interactive: {\n      true: \"shrink-0 rounded-full text-muted-foreground transition-colors duration-fast ease-out-expo outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 [&>svg]:transition-[scale] [&>svg]:duration-spring-press [&>svg]:ease-spring-press active:[&>svg]:scale-(--press-squeeze)\",\n      false: \"\",\n    },\n  },\n  defaultVariants: {\n    size: \"default\",\n    interactive: false,\n  },\n})\n\ninterface BreadcrumbProps extends React.ComponentProps<\"nav\"> {\n  /** Trail-wide type scale. `sm` is for dense chrome — a sticky topbar sitting\n   *  beside small controls — not for page headers. */\n  size?: BreadcrumbSize\n  /** Glyph every `BreadcrumbSeparator` in this trail renders unless it\n   *  overrides it locally or is given explicit children. */\n  separator?: BreadcrumbSeparatorKind\n}\n\ntype BreadcrumbListProps = React.ComponentProps<\"ol\">\n\ntype BreadcrumbItemProps = React.ComponentProps<\"li\">\n\ninterface BreadcrumbLinkProps extends React.ComponentProps<\"a\"> {\n  asChild?: boolean\n}\n\ntype BreadcrumbPageProps = React.ComponentProps<\"span\">\n\ninterface BreadcrumbSeparatorProps extends React.ComponentProps<\"li\"> {\n  /** Per-joint override. The root's `separator` supplies the default, and\n   *  explicit `children` still beat both. */\n  variant?: BreadcrumbSeparatorKind\n}\n\ninterface BreadcrumbEllipsisProps extends React.ComponentProps<\"span\"> {\n  /** Renders the ellipsis as a real control so it can be a menu trigger.\n   *  Supply a single element child to slot into, or omit children and a\n   *  `<button>` is used. */\n  asChild?: boolean\n  /** Accessible name for the trigger form. Rendered as visually hidden text\n   *  rather than aria-label so it is translatable and survives extraction. */\n  label?: string\n}\n\nfunction Breadcrumb({\n  size = \"default\",\n  separator = \"chevron\",\n  className,\n  children,\n  ...props\n}: BreadcrumbProps) {\n  const context = React.useMemo(() => ({ size, separator }), [size, separator])\n\n  return (\n    <nav\n      aria-label=\"breadcrumb\"\n      data-slot=\"breadcrumb\"\n      data-size={size}\n      className={cn(className)}\n      {...props}\n    >\n      <BreadcrumbContext.Provider value={context}>\n        {children}\n      </BreadcrumbContext.Provider>\n    </nav>\n  )\n}\n\nfunction BreadcrumbList({ className, ...props }: BreadcrumbListProps) {\n  const { size } = useBreadcrumb()\n\n  return (\n    <ol\n      data-slot=\"breadcrumb-list\"\n      className={cn(breadcrumbListVariants({ size }), className)}\n      {...props}\n    />\n  )\n}\n\nfunction BreadcrumbItem({ className, ...props }: BreadcrumbItemProps) {\n  return (\n    <li\n      data-slot=\"breadcrumb-item\"\n      className={cn(\"inline-flex items-center gap-1\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction BreadcrumbLink({ asChild, className, ...props }: BreadcrumbLinkProps) {\n  const { size } = useBreadcrumb()\n  const Comp = asChild ? Slot.Root : \"a\"\n\n  return (\n    <Comp\n      data-slot=\"breadcrumb-link\"\n      className={cn(breadcrumbLinkVariants({ size }), className)}\n      {...props}\n    />\n  )\n}\n\nfunction BreadcrumbPage({ className, ...props }: BreadcrumbPageProps) {\n  const { size } = useBreadcrumb()\n\n  return (\n    <span\n      data-slot=\"breadcrumb-page\"\n      role=\"link\"\n      aria-disabled=\"true\"\n      aria-current=\"page\"\n      className={cn(breadcrumbPageVariants({ size }), className)}\n      {...props}\n    />\n  )\n}\n\n/* Every kind stays inside the presentational, aria-hidden li, which is what\n * keeps the trail reading as \"Workspace, Agents, Overview\" instead of\n * \"Workspace, greater-than, Agents\". The two arrows flip in RTL; a slash, a dot\n * and a hairline are direction-agnostic and must not. */\nfunction BreadcrumbSeparatorGlyph({\n  variant,\n  size,\n}: {\n  variant: BreadcrumbSeparatorKind\n  size: BreadcrumbSize\n}) {\n  switch (variant) {\n    case \"slash\":\n      return <SlashIcon />\n    case \"arrow\":\n      return <ArrowRightIcon className=\"rtl:rotate-180\" />\n    case \"dot\":\n      return <span className=\"size-1 shrink-0 rounded-full bg-current\" />\n    case \"line\":\n      return (\n        <span\n          className={cn(\n            \"w-px shrink-0 bg-border\",\n            size === \"sm\" ? \"h-3.5\" : \"h-4\"\n          )}\n        />\n      )\n    default:\n      return <ChevronRightIcon className=\"rtl:rotate-180\" />\n  }\n}\n\nfunction BreadcrumbSeparator({\n  variant,\n  children,\n  className,\n  ...props\n}: BreadcrumbSeparatorProps) {\n  const { size, separator } = useBreadcrumb()\n  const resolved = variant ?? separator\n\n  return (\n    <li\n      data-slot=\"breadcrumb-separator\"\n      role=\"presentation\"\n      aria-hidden=\"true\"\n      className={cn(\n        breadcrumbSeparatorVariants({ variant: resolved, size }),\n        className\n      )}\n      {...props}\n    >\n      {children ?? <BreadcrumbSeparatorGlyph variant={resolved} size={size} />}\n    </li>\n  )\n}\n\n/* Two forms, one part.\n *\n * Decorative (the default) is a glyph inside an aria-hidden span — silent,\n * because collapsed crumbs that cannot be reached are not worth announcing.\n * There is deliberately no visually hidden text here: the usual shape puts one\n * inside the aria-hidden subtree, where nothing can ever read it.\n *\n * Trigger (`asChild`) drops the aria-hidden entirely, renders through Slot so a\n * menu trigger's props and ref land on a real focusable element, and carries a\n * visually hidden `label` so that element finally has an accessible name:\n *\n *   <DropdownMenuTrigger asChild>\n *     <BreadcrumbEllipsis asChild label=\"Show 3 hidden pages\" />\n *   </DropdownMenuTrigger>\n *\n * The children are built as an array rather than a fragment on purpose — Slot\n * walks its children looking for the Slottable, and a fragment would hide it. */\nfunction BreadcrumbEllipsis({\n  asChild,\n  label = \"More pages\",\n  className,\n  children,\n  ...props\n}: BreadcrumbEllipsisProps) {\n  const { size } = useBreadcrumb()\n  const Comp = asChild ? Slot.Root : \"span\"\n\n  const content = asChild\n    ? [\n        <MoreHorizontalIcon key=\"glyph\" aria-hidden=\"true\" />,\n        <span key=\"label\" className=\"sr-only\">\n          {label}\n        </span>,\n        <Slot.Slottable key=\"target\">\n          {children ?? <button type=\"button\" />}\n        </Slot.Slottable>,\n      ]\n    : (children ?? <MoreHorizontalIcon />)\n\n  return (\n    <Comp\n      data-slot=\"breadcrumb-ellipsis\"\n      role={asChild ? undefined : \"presentation\"}\n      aria-hidden={asChild ? undefined : true}\n      className={cn(\n        breadcrumbEllipsisVariants({ size, interactive: Boolean(asChild) }),\n        className\n      )}\n      {...props}\n    >\n      {content}\n    </Comp>\n  )\n}\n\nexport {\n  Breadcrumb,\n  BreadcrumbList,\n  BreadcrumbItem,\n  BreadcrumbLink,\n  BreadcrumbPage,\n  BreadcrumbSeparator,\n  BreadcrumbEllipsis,\n  breadcrumbListVariants,\n  breadcrumbLinkVariants,\n  breadcrumbPageVariants,\n  breadcrumbSeparatorVariants,\n  breadcrumbEllipsisVariants,\n}\n\nexport type {\n  BreadcrumbProps,\n  BreadcrumbListProps,\n  BreadcrumbItemProps,\n  BreadcrumbLinkProps,\n  BreadcrumbPageProps,\n  BreadcrumbSeparatorProps,\n  BreadcrumbEllipsisProps,\n  BreadcrumbSize,\n  BreadcrumbSeparatorKind,\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}