{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "family-bar",
  "title": "FamilyBar",
  "description": "The slim strip above a site's own header that links every site of a family, the same links in the same order on each, with the site being shown marked `aria-current=\"true\"`, in the text colour, underlined in the primary colour as Navbar marks the current page.",
  "registryDependencies": [
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-router-link",
    "@ouro/lib-scroll-fade",
    "@ouro/lib-use-dev-messages"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/family-bar/family-bar-styles.ts",
      "content": "export { familyBarClass, familyExtrasClass, familyFooterClass, familyFooterLinkClass, familyFooterListClass, familyLinkClass, familyScrollerClass, familyWarnings };\n\nimport type { DevWarning } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\n\n/**\n * A link in a FamilyBar or a FamilyFooter: regular weight in the muted foreground, so the family's chrome never\n * outweighs a site's own navigation. The current site's link is in the foreground, underlined in the primary colour:\n * the mark Navbar and NavigationMenu give the current page, which forced colours keep. The focus outline is inset,\n * inside the row that scrolls. On a coarse pointer a link is at least 44px each way, so a site with a two-letter name is\n * as easy to tap as the rest.\n *\n * @claim \"so the family's chrome never outweighs a site's own navigation\" registry/ouro/components/ouro/family-bar/family-bar.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-bar.test.tsx::FamilyBar > renders a labelled nav of the family's links in order, at regular weight, the current site marked with aria-current, the text colour and a bar under it)\n * @claim \"On a coarse pointer a link is at least 44px each way, so a site with a two-letter name is as easy to tap as the rest.\" registry/ouro/components/ouro/family-bar/family-bar.touch.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-bar.touch.test.tsx::FamilyBar and FamilyFooter on a phone > keep 44px targets with 16px text, a two-letter name too, also in landscape, and the page never scrolls sideways)\n *\n * @internal\n */\nconst familyLinkClass =\n  \"relative m-0 box-border inline-flex min-h-11 min-w-11 pointer-fine:min-h-8 pointer-fine:min-w-0 items-center justify-center rounded-ouro-md px-2.5 whitespace-nowrap no-underline select-none touch-manipulation \" +\n  \"text-base pointer-fine:text-sm leading-5 font-normal text-muted-foreground [-webkit-tap-highlight-color:transparent] \" +\n  \"transition-colors duration-(--ouro-duration-fast) ease-[ease] pointer-fine:hover:text-foreground active:text-foreground \" +\n  \"aria-[current=true]:text-foreground aria-[current=true]:underline aria-[current=true]:decoration-primary aria-[current=true]:decoration-2 \" +\n  \"aria-[current=true]:underline-offset-5 aria-[current=true]:[text-decoration-skip-ink:none] \" +\n  \"outline-ring -outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid\";\n\n/**\n * The FamilyBar's strip: one row on the page's own colour with a hairline under it, set apart from the site's own header\n * below it without a surface of its own, and clear of a phone's rounded corners. Its padding is the FamilyFooter's, and\n * its first link's text, like the footer's, starts at the padding's edge, so a page's bar, logo and footer can share one\n * column edge.\n *\n * @claim \"its first link's text, like the footer's, starts at the padding's edge\" registry/ouro/components/ouro/family-bar/family-bar.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-bar.test.tsx::FamilyBar > starts its first link's text where the FamilyFooter's does, at the padding's edge, with the same padding, or after its brand)\n *\n * @internal\n */\nconst familyBarClass =\n  \"box-border flex w-full min-w-0 items-center gap-2 border-0 border-b border-solid border-border bg-background text-foreground \" +\n  \"ps-[max(1rem,env(safe-area-inset-left,0px))] pe-[max(1rem,env(safe-area-inset-right,0px))]\";\n\n/**\n * The FamilyBar's row of links, which scrolls inside itself when it does not fit; a swipe comes to rest with a whole\n * link at its start, past the fade. Without a brand before it, the row starts a link's padding before the bar's padding,\n * so the first link's text starts at the padding's edge. A mouse and the keyboard scroll it exactly, without snapping. A finger swipes it, so on a coarse\n * pointer its scroll bar is hidden; a mouse wheel scrolls up and down, so on a fine pointer a thin, quiet scroll bar\n * stays to drag. Its scroll padding is as wide as the fade, and a link the keyboard focuses is brought clear of it,\n * outline and all.\n *\n * @claim \"Its scroll padding is as wide as the fade, and a link the keyboard focuses is brought clear of it, outline and all.\" registry/ouro/components/ouro/family-bar/family-bar.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-bar.test.tsx::FamilyBar > brings each link the keyboard focuses clear of the row's fade, outline and all)\n *\n * @internal\n */\nconst familyScrollerClass =\n  \"@container min-w-0 flex-1 first:-ms-2.5 overflow-x-auto overflow-y-hidden overscroll-x-contain pointer-coarse:snap-x pointer-coarse:snap-proximity scroll-px-8 \" +\n  \"[scrollbar-width:thin] [scrollbar-color:var(--border)_transparent] pointer-coarse:[scrollbar-width:none]\";\n\n/**\n * A link in a FamilyFooter's list: a FamilyBar link that looks like a link at rest, underlined in the border colour and\n * in its own colour on hover; the current site's link is underlined in the primary colour, as in the bar. Forced colours\n * paint the links in the link colour, so there the current site's link alone keeps its underline, as in the bar. In a\n * narrow footer the links fill even columns, a whole row each 44px tall, rather than wrapping into ragged lines; a long\n * name wraps inside its column.\n *\n * @claim \"Forced colours paint the links in the link colour, so there the current site's link alone keeps its underline\" registry/ouro/components/ouro/family-bar/family-footer.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-footer.test.tsx::FamilyFooter > keeps only the current site's underline under forced colours, which drop colour, as the bar does)\n * @claim \"In a narrow footer the links fill even columns, a whole row each 44px tall\" registry/ouro/components/ouro/family-bar/family-footer.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-footer.test.tsx::FamilyFooter > lays its links in even columns of 44px rows on a narrow screen instead of ragged lines, and never scrolls sideways)\n *\n * @internal\n */\nconst familyFooterLinkClass =\n  \"underline decoration-border decoration-1 underline-offset-4 pointer-fine:not-aria-[current=true]:hover:decoration-current forced-colors:not-aria-[current=true]:no-underline \" +\n  \"max-sm:min-h-11 max-sm:pointer-fine:min-h-11 max-sm:max-w-full max-sm:justify-start max-sm:whitespace-normal max-sm:text-start\";\n\n/**\n * The FamilyFooter's list of links: even columns in a narrow footer, one row that wraps in a wide one.\n *\n * @internal\n */\nconst familyFooterListClass =\n  \"m-0 -ms-2.5 grid list-none grid-cols-[repeat(auto-fill,minmax(8.5rem,1fr))] items-center gap-x-0.5 p-0 sm:flex sm:flex-wrap\";\n\n/**\n * The FamilyFooter: its links and the site's own extras on one row that wraps, over a hairline.\n *\n * @internal\n */\nconst familyFooterClass =\n  \"box-border flex w-full min-w-0 flex-wrap items-center justify-between gap-x-6 gap-y-2 border-0 border-t border-solid border-border bg-background py-4 text-muted-foreground \" +\n  \"ps-[max(1rem,env(safe-area-inset-left,0px))] pe-[max(1rem,env(safe-area-inset-right,0px))]\";\n\n/**\n * The FamilyFooter's area for the site's own extras: it takes the rest of the row after the family's links, or a whole\n * row of its own when it wraps, so the site lays out its extras across it, to the row's end edge. They sit at that end\n * on a wide screen, and at the start on a phone, under the links, until the site spreads them: `me-auto` on the first.\n *\n * @claim \"it takes the rest of the row after the family's links, or a whole row of its own when it wraps\" registry/ouro/components/ouro/family-bar/family-footer.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-footer.test.tsx::FamilyFooter > lets the site's extras fill the rest of the row, or a row of their own, to its end edge)\n *\n * @internal\n */\nconst familyExtrasClass =\n  \"flex min-w-0 flex-[1_1_auto] flex-wrap items-center justify-end gap-x-4 gap-y-1 text-base pointer-fine:text-sm max-sm:basis-full max-sm:justify-start\";\n\n/**\n * The development messages FamilyBar and FamilyFooter share: a `current` that is not a link's id, and a repeated link id.\n *\n * @internal\n */\nfunction familyWarnings(component: string, links: readonly { id: string }[], current: string | undefined): DevWarning[] {\n  const ids = links.map((link) => link.id);\n  const twice = ids.find((id, index) => ids.indexOf(id) !== index);\n  return [\n    current !== undefined && !ids.includes(current) && [`current \"${current}\" matches no link's id`, `<${component} current=\"${ids[0] ?? \"home\"}\">`],\n    twice !== undefined && [`two links have the id \"${twice}\"`, `links={[{ id: \"${twice}\", … }, { id: \"${twice}-2\", … }]}`],\n  ];\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/family-bar/family-bar-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/family-bar/family-bar.tsx",
      "content": "\"use client\";\n\nimport { useLayoutEffect, useRef, type FocusEvent, type JSX, type ReactNode, type Ref } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { RouterLink } from \"@/registry/ouro/lib/ouro/router-link\";\nimport { scrollFadeClass, scrollFadeStaticClass, useScrollFade } from \"@/registry/ouro/lib/ouro/scroll-fade\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { familyBarClass, familyLinkClass, familyScrollerClass, familyWarnings } from \"@/registry/ouro/components/ouro/family-bar/family-bar-styles\";\n\n// Scrolls `row` the least that brings `link` clear of the row's scroll padding, which is as wide as its fade; a link\n// already clear stays put. Physical offsets, which hold in a right-to-left row too.\nfunction reveal(row: HTMLElement, link: Element) {\n  const pad = parseFloat(getComputedStyle(row).scrollPaddingLeft);\n  const box = row.getBoundingClientRect();\n  const at = link.getBoundingClientRect();\n  row.scrollLeft += Math.min(at.left - box.left - pad, 0) || Math.max(at.right - box.right + pad, 0);\n}\n\n/** One site of a family, in a FamilyBar and a FamilyFooter. */\nexport interface FamilyLink {\n  /** Names the site for `current`: \"docs\". It is not shown. */\n  id: string;\n  /** The site's name, the link's text: \"Docs\". */\n  label: string;\n  /** Where the link goes: the site's home page, \"https://docs.example.com/\". */\n  href: string;\n}\n\n/** Props for {@link FamilyBar}. */\nexport interface FamilyBarProps {\n  /** The family's sites, in order. Give every site the same list in the same order, so the bar reads the same on each. */\n  links: readonly FamilyLink[];\n  /**\n   * The `id` of the site being shown. Its link gets `aria-current=\"true\"`, the text colour and a primary underline, so the mark\n   * is not colour alone.\n   */\n  current?: string | undefined;\n  /** Names the navigation for screen readers. It is not shown. @default \"Sites\" */\n  label?: string | undefined;\n  /** The family's mark or name, before the links. It stays in place while the links scroll. */\n  brand?: ReactNode;\n  /** Layout only: position (`sticky top-0`), grid placement. Appearance classes warn in development. */\n  className?: string | undefined;\n  ref?: Ref<HTMLElement> | undefined;\n\n  /** Not a prop. FamilyBar takes `links`: `<FamilyBar links={[{ id: \"docs\", label: \"Docs\", href: \"/\" }]} />`. */\n  items?: { 'Use <FamilyBar links={[{ id: \"docs\", label: \"Docs\", href: \"/\" }]} />': never };\n  /** Not a prop. FamilyBar marks a site by its id, not by a path: `<FamilyBar current=\"docs\">`. */\n  currentPath?: { 'Use <FamilyBar current=\"docs\">, the id of the site shown': never };\n  /** Not rendered. The bar is `links` and `brand`. */\n  children?: { \"Use links={[{ id, label, href }]} and brand={...}\": never };\n}\n\nconst example = '<FamilyBar links={[{ id: \"docs\", label: \"Docs\", href: \"/\" }]} />';\n\n/**\n * The slim strip above a site's own header that links every site of a family, the same links in the same order on each,\n * with the site being shown marked `aria-current=\"true\"`, in the text colour, underlined in the primary colour as Navbar marks the current page. A labelled `<nav>` of\n * plain links: the server HTML is the whole bar, so a page that never hydrates shows it as is. On a narrow screen the\n * row scrolls inside itself, never the page, and fades at the side that hides more links, so a name cut at the edge\n * reads as more to come. In browsers that support it the fade and the current site's link in view need no script.\n * Once hydrated, the row fades in any browser and brings the current site's link into view when it is out of view. Links render through `OuroProvider`'s `linkComponent`, so a link to the site's own path stays in its\n * router.\n *\n * Use `Navbar` instead for a site's own pages, under the FamilyBar, and `FamilyFooter` for the same links at the foot of\n * the page.\n *\n * @group Navigation\n * @see https://ui.ouroboros.bot/docs/family-bar\n * @claim \"links every site of a family\" registry/ouro/components/ouro/family-bar/family-bar.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-bar.test.tsx::FamilyBar > renders a labelled nav of the family's links in order, at regular weight, the current site marked with aria-current, the text colour and a bar under it)\n * @claim \"the server HTML is the whole bar\" registry/ouro/components/ouro/family-bar/family-bar.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-bar.test.tsx::FamilyBar > renders the whole bar in the server HTML)\n * @claim \"fades at the side that hides more links\" registry/ouro/components/ouro/family-bar/family-bar.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-bar.test.tsx::FamilyBar > fades the side of the row that hides more in the server HTML alone, with no script, and nothing in a row that fits)\n * @claim \"In browsers that support it the fade and the current site's link in view need no script\" registry/ouro/components/ouro/family-bar/family-bar.test.tsx verify:testExists(registry/ouro/components/ouro/family-bar/family-bar.test.tsx::FamilyBar > starts the row with the current site's link in view from the server HTML alone, where the browser supports scroll-initial-target) verify:testExists(registry/ouro/components/ouro/family-bar/family-bar.test.tsx::FamilyBar > fades the side of the row that hides more in the server HTML alone, with no script, and nothing in a row that fits) verify:testExists(registry/ouro/components/ouro/family-bar/family-bar.test.tsx::FamilyBar > leaves the row where it starts when the current site's link is already in view, with or without script)\n *\n * @example\n * <FamilyBar\n *   label=\"Sites\"\n *   links={[\n *     { id: \"home\", label: \"Lantern\", href: \"https://example.com/\" },\n *     { id: \"docs\", label: \"Docs\", href: \"https://docs.example.com/\" },\n *     { id: \"blog\", label: \"Blog\", href: \"https://blog.example.com/\" },\n *   ]}\n *   current=\"docs\"\n * />\n */\nexport function FamilyBar(props: FamilyBarProps): JSX.Element {\n  const {\n    links,\n    current,\n    label = \"Sites\",\n    brand,\n    className,\n    ref,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    items,\n    currentPath,\n    children,\n  } = props;\n  useAppearanceClassNameCheck(\n    \"FamilyBar\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; FamilyBar sets its own look`\n      : // Stryker disable next-line StringLiteral: production only; the check never runs there.\n        /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"FamilyBar\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          ...familyWarnings(\"FamilyBar\", links, current),\n          items !== undefined && [\"items is not a prop\", example],\n          currentPath !== undefined && [\"currentPath is not a prop; current takes the id of the site being shown\", '<FamilyBar current=\"docs\">'],\n          children !== undefined && [\"children are not rendered\", example],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  const scroller = useRef<HTMLDivElement>(null);\n  useScrollFade(scroller);\n  // Before paint, so the row never shows the current site's link out of view first; a link already in view, and a row\n  // that fits, stay where they are.\n  useLayoutEffect(() => {\n    const row = scroller.current!;\n    const link = row.querySelector('[aria-current=\"true\"]');\n    if (link) reveal(row, link);\n  }, [current]);\n\n  // The browser scrolls a focused link only until it is in view, which can leave it, outline and all, in the fade at\n  // the row's edge. Keyboard focus brings it clear; a pointer's does not, so the link a click lands on never moves\n  // under it.\n  function clearOfFade(event: FocusEvent<HTMLUListElement>) {\n    if (event.target.matches(\":focus-visible\")) reveal(scroller.current!, event.target);\n  }\n\n  return (\n    <nav ref={ref} data-ouro=\"family-bar\" aria-label={label} className={cn(familyBarClass, className)}>\n      {brand !== undefined && (\n        <div data-ouro-family-brand=\"\" className=\"flex shrink-0 items-center\">\n          {brand}\n        </div>\n      )}\n      <div ref={scroller} data-ouro-family-row=\"\" className={cn(familyScrollerClass, scrollFadeClass, scrollFadeStaticClass)}>\n        {/* Room after the last link: the row's scroll width rounds the list's down, which would clip the last link and\n            its outline by a fraction of a pixel when the row is scrolled to its end. */}\n        {/* Where scroll-driven animations draw the fade with no script, the list is a pixel wider than a row it fits on a\n            touch screen, so the row's scroll timeline never goes idle and holds a stale fade after a phone turns. Not for\n            a mouse, whose row keeps a scroll bar a pixel would show. */}\n        <ul\n          onFocus={clearOfFade}\n          className=\"m-0 flex w-max list-none items-center gap-0.5 p-0 pe-1 pointer-coarse:supports-[animation-timeline:scroll()]:min-w-[calc(100%+1px)]\"\n        >\n          {links.map((link, index) => (\n            <li key={index} className=\"relative flex snap-start\">\n              <RouterLink\n                href={link.href}\n                aria-current={link.id === current ? \"true\" : undefined}\n                data-ouro-control=\"family-bar\"\n                data-ouro-part=\"link\"\n                className={familyLinkClass}\n              >\n                {link.label}\n              </RouterLink>\n              {link.id === current && (\n                // Where the row starts with no script: the browser scrolls a scroll-initial-target to the row's start,\n                // so this mark sits a row's width less twice the fade before the link's end. The row starts scrolled\n                // just far enough to bring the link clear of the fade, and not at all when it already is.\n                <span aria-hidden=\"true\" data-ouro-family-start=\"\" className=\"pointer-events-none absolute top-0 end-[calc(100cqw-4rem)] size-px [scroll-initial-target:nearest]\" />\n              )}\n            </li>\n          ))}\n        </ul>\n      </div>\n    </nav>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/family-bar/family-bar.tsx"
    }
  ],
  "docs": "The slim strip above a site's own header that links every site of a family, the same links in the same order on each, with the site being shown marked `aria-current=\"true\"`, in the text colour, underlined in the primary colour as Navbar marks the current page. Import: import { FamilyBar } from \"@/components/ouro/family-bar/family-bar\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: the helpers it imports in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/family-bar.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}