{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tabs",
  "title": "Tabs",
  "description": "Tabs that switch between panels in place: an accessible tab list with roving focus, arrow-key navigation, a line that slides to the selected tab, and 44px tabs on touch screens.",
  "dependencies": [
    "@base-ui/react@^1.8.0"
  ],
  "registryDependencies": [
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-current-path",
    "@ouro/lib-dev",
    "@ouro/lib-env",
    "@ouro/lib-page-direction",
    "@ouro/lib-refs",
    "@ouro/lib-router-link",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-media-query"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/tabs/tabs-parts.tsx",
      "content": "\"use client\";\n\nimport { Tabs as BaseTabs } from \"@base-ui/react/tabs\";\nimport { createContext, memo, useContext, useEffect, useRef, type JSX, type ReactNode } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { PageDirection } from \"@/registry/ouro/lib/ouro/page-direction\";\nimport { devThrow } from \"@/registry/ouro/lib/ouro/dev\";\nimport { useMergedRef } from \"@/registry/ouro/lib/ouro/refs\";\nimport {\n  indicatorClass,\n  linkListClass,\n  listClass,\n  ownLook,\n  panelClass,\n  rootClass,\n  tabClass,\n  tabFaceClass,\n  type TabsOrientation,\n} from \"@/registry/ouro/components/ouro/tabs/tabs-styles\";\n\nconst TabsContext = createContext(false);\n\n/** Throws in development, with the JSX the part belongs in, unless it sits inside a TabsRoot. */\nfunction useTabsPart(part: string, inner: string): void {\n  if (!useContext(TabsContext)) {\n    devThrow(\n      part,\n      \"must be rendered inside <TabsRoot>\",\n      process.env.NODE_ENV !== \"production\"\n        ? `<TabsRoot defaultValue=\"…\"><TabsList aria-label=\"…\"><TabsTab value=\"…\">…</TabsTab><TabsIndicator /></TabsList><TabsPanel value=\"…\">…</TabsPanel></TabsRoot>, with ${inner} in its place`\n        : /* istanbul ignore next @preserve -- production only */ \"\",\n    );\n  }\n}\n\n/** Runs the className check for a part, with a hint only in development. */\nfunction usePartClassName(part: string, className: unknown): void {\n  useAppearanceClassNameCheck(\n    part,\n    typeof className === \"string\" ? className : undefined,\n    process.env.NODE_ENV !== \"production\" ? ownLook(part) : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n}\n\n/** Props for {@link TabsRoot}. `className` is for layout only. */\nexport type TabsRootProps = Omit<BaseTabs.Root.Props, \"className\"> & { className?: string | undefined };\n\n/**\n * Part: the state owner of tabs built from parts. Use the `Tabs` component instead\n * unless its `items` cannot express your layout, such as a tab that holds a badge next to\n * its label or a panel shared by two tabs.\n *\n * @example\n * <TabsRoot defaultValue=\"ingredients\">\n *   <TabsList aria-label=\"Recipe\">\n *     <TabsTab value=\"ingredients\">Ingredients</TabsTab>\n *     <TabsTab value=\"method\">Method</TabsTab>\n *     <TabsIndicator />\n *   </TabsList>\n *   <TabsPanel value=\"ingredients\">…</TabsPanel>\n *   <TabsPanel value=\"method\">…</TabsPanel>\n * </TabsRoot>\n */\nexport function TabsRoot(props: TabsRootProps): JSX.Element {\n  usePartClassName(\"TabsRoot\", props.className);\n  return <TabsRootUnchecked {...props} />;\n}\n\n/**\n * The root without its own className check, for `Tabs`, which checks its own.\n *\n * @internal\n */\nexport function TabsRootUnchecked({ className, onPointerDownCapture, ref, ...props }: TabsRootProps): JSX.Element {\n  const root = useRef<HTMLDivElement>(null);\n  const merged = useMergedRef(ref, root);\n  return (\n    <TabsContext.Provider value>\n      <PageDirection of={root}>\n        <BaseTabs.Root\n          {...props}\n          ref={merged}\n          data-ouro=\"tabs\"\n          // A pointer anywhere inside (a tab, or a control in a panel) ends the keyboard's quiet spell.\n          onPointerDownCapture={(event) => {\n            event.currentTarget.toggleAttribute(\"data-ouro-keyboard\", false);\n            onPointerDownCapture?.(event);\n          }}\n          className={cn(rootClass, className)}\n        />\n      </PageDirection>\n    </TabsContext.Provider>\n  );\n}\n\n/** Props for {@link TabsList}. Name the list with `aria-label`. */\nexport type TabsListProps = Omit<BaseTabs.List.Props, \"className\"> & { className?: string | undefined };\n\n/**\n * Marks which sides of a scrolling tab row hide more tabs, as `data-fade=\"left\"`, `\"right\"` or\n * `\"both\"`, so the row fades out on that edge. Physical sides, so the CSS needs no direction.\n * @claim \"Physical sides, so the CSS needs\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > fades the leading edge on the right in a right-to-left row)\n */\nfunction useEdgeFade(list: { current: HTMLElement | null }): void {\n  useEffect(() => {\n    const element = list.current!;\n    const update = () => {\n      const horizontal = element.getAttribute(\"aria-orientation\") !== \"vertical\";\n      // In a right-to-left row, scrollLeft runs from 0 down to a negative number.\n      const scrolled = Math.abs(element.scrollLeft);\n      const before = horizontal && scrolled > 1;\n      const after = horizontal && scrolled + element.clientWidth < element.scrollWidth - 1;\n      // The direction matters only when a side hides tabs, so a row that fits reads no style.\n      const rtl = (before || after) && getComputedStyle(element).direction === \"rtl\";\n      const [left, right] = rtl ? [after, before] : [before, after];\n      const fade = left && right ? \"both\" : left ? \"left\" : right ? \"right\" : null;\n      if (fade) element.setAttribute(\"data-fade\", fade);\n      else element.removeAttribute(\"data-fade\");\n    };\n    update();\n    element.addEventListener(\"scroll\", update, { passive: true });\n    const resize = new ResizeObserver(update);\n    resize.observe(element);\n    // The orientation can change, and tabs can come and go.\n    const mutation = new MutationObserver(update);\n    mutation.observe(element, { attributes: true, attributeFilter: [\"aria-orientation\"], childList: true });\n    return () => {\n      element.removeEventListener(\"scroll\", update);\n      resize.disconnect();\n      mutation.disconnect();\n    };\n  }, [list]);\n}\n\n/**\n * Part: the row (or column) of tabs. Name it with `aria-label` when the page has more than\n * one set of tabs. `activateOnFocus` selects a tab when the arrow keys focus it. A row that\n * scrolls, on a phone, fades out on the side that hides more tabs. A key that moves the\n * selection switches tabs without animation.\n */\nexport function TabsList({ className, ref, onKeyDownCapture, ...props }: TabsListProps): JSX.Element {\n  useTabsPart(\"TabsList\", '<TabsList aria-label=\"…\">…</TabsList>');\n  usePartClassName(\"TabsList\", className);\n  const own = useRef<HTMLDivElement>(null);\n  const merged = useMergedRef(ref, own);\n  useEdgeFade(own);\n  // The tabs say when a key moved the selection (the root clears it on a pointer), so switching\n  // by key doesn't animate the indicator or the panel.\n  return (\n    <BaseTabs.List\n      {...props}\n      ref={merged}\n      onKeyDownCapture={(event) => {\n        event.currentTarget.closest('[data-ouro=\"tabs\"]')!.toggleAttribute(\"data-ouro-keyboard\", true);\n        onKeyDownCapture?.(event);\n      }}\n      className={cn(listClass, className)}\n    />\n  );\n}\n\n/**\n * The list of Tabs' links, in the tab row's look, fading the side of a scrolling row that\n * hides more links. The fade treats the list as a row (a list cannot carry `aria-orientation`):\n * a column of links is as wide as its widest link, so it has nothing to fade. It scrolls the\n * link to the current page (`current`, its value) into view.\n *\n * @internal Used by Tabs when its items are links; apps pass `items` with `href`.\n */\nexport function TabsLinkList({ orientation, current, children }: { orientation: TabsOrientation; current: string | undefined; children: ReactNode }): JSX.Element {\n  const own = useRef<HTMLUListElement>(null);\n  useEdgeFade(own);\n  // A row that scrolls, on a phone, brings the current page's link into view, as a row of tabs\n  // brings the selected tab, without scrolling the page.\n  useEffect(() => {\n    const list = own.current!;\n    const here = list.querySelector('[aria-current=\"page\"]');\n    if (!here) return;\n    const [box, link] = [list.getBoundingClientRect(), here.getBoundingClientRect()];\n    // Back by what hides past the start, or on by what hides past the end; nothing when it shows.\n    list.scrollLeft += Math.min(link.left - box.left, 0) + Math.max(link.right - box.right, 0);\n  }, [current, orientation]);\n  return (\n    <ul ref={own} data-orientation={orientation} className={cn(listClass, linkListClass)}>\n      {children}\n    </ul>\n  );\n}\n\n/** Props for {@link TabsTab}. */\nexport type TabsTabProps = Omit<BaseTabs.Tab.Props, \"className\"> & { className?: string | undefined };\n\n/** Part: one tab, a button that shows the panel with the same `value`. */\nexport function TabsTab({ className, children, ...props }: TabsTabProps): JSX.Element {\n  useTabsPart(\"TabsTab\", '<TabsTab value=\"…\">…</TabsTab>');\n  usePartClassName(\"TabsTab\", className);\n  return (\n    <BaseTabs.Tab data-ouro-control=\"tabs\" data-ouro-part=\"tab\" {...props} className={cn(tabClass, className)}>\n      <span className={tabFaceClass}>{children}</span>\n    </BaseTabs.Tab>\n  );\n}\n\n/** Part: the line that slides to the selected tab. Put it last inside `TabsList`. */\nexport const TabsIndicator = memo(function TabsIndicator(props: Omit<BaseTabs.Indicator.Props, \"className\">): JSX.Element {\n  useTabsPart(\"TabsIndicator\", \"<TabsIndicator />\");\n  return <BaseTabs.Indicator {...props} data-ouro-tabs-indicator=\"\" className={indicatorClass} />;\n});\n\n/** Props for {@link TabsPanel}. */\nexport type TabsPanelProps = Omit<BaseTabs.Panel.Props, \"className\"> & { className?: string | undefined };\n\n/** Part: the content shown while the tab with the same `value` is selected. */\nexport function TabsPanel({ className, ...props }: TabsPanelProps): JSX.Element {\n  useTabsPart(\"TabsPanel\", '<TabsPanel value=\"…\">…</TabsPanel>');\n  usePartClassName(\"TabsPanel\", className);\n  return <BaseTabs.Panel data-ouro-control=\"tabs\" data-ouro-part=\"panel\" {...props} className={cn(panelClass, className)} />;\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/tabs/tabs-parts.tsx"
    },
    {
      "path": "registry/ouro/components/ouro/tabs/tabs-styles.ts",
      "content": "export {\n  activations,\n  indicatorClass,\n  linkIndicatorClass,\n  linkItemClass,\n  linkListClass,\n  listClass,\n  orientations,\n  ownLook,\n  panelClass,\n  rootClass,\n  tabClass,\n  tabFaceClass,\n  tabLinkClass,\n};\nexport type { TabsActivation, TabsOrientation };\n\n// Class strings and value lists for Tabs, apart from the components so their files export\n// only components (React Fast Refresh). Class strings are literal so the app's Tailwind\n// finds them when it compiles.\n\n/**\n * The layouts Tabs supports: tabs in a row above the panel, or in a column beside it.\n *\n * @internal\n * @claim \"The layouts Tabs supports: tabs in\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > puts vertical tabs in a row above the panel on a narrow screen)\n * @claim \"The layouts Tabs supports: tabs in\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > renders a labelled tab list with the first tab selected and its panel shown)\n */\nconst orientations = [\"horizontal\", \"vertical\"] as const;\n\n/** `horizontal` puts the tabs in a row above the panel; `vertical` in a column beside it. */\ntype TabsOrientation = (typeof orientations)[number];\n\n/**\n * How the keyboard selects a tab.\n *\n * @internal\n */\nconst activations = [\"automatic\", \"manual\"] as const;\n\n/** `automatic` selects a tab when the arrow keys focus it; `manual` waits for Enter or Space. */\ntype TabsActivation = (typeof activations)[number];\n\n/**\n * The `Fix:` for an appearance class on a part that draws its own look.\n *\n * @internal\n */\nfunction ownLook(component: string): (token: string) => string {\n  return (token) => `remove \"${token}\"; ${component} sets its own look`;\n}\n\n/**\n * The root: the list above (or beside) the panel.\n *\n * @internal\n */\nconst rootClass = \"flex min-w-0 gap-4 data-[orientation=horizontal]:flex-col data-[orientation=vertical]:flex-row\";\n\n/**\n * The tab list. A hairline under the row (or on the column's end edge, the left in a right-to-left page) is an inset shadow, not a\n * border, so the row can scroll sideways on a narrow screen without clipping the indicator.\n * While it scrolls, a mask fades the side that hides more tabs (`data-fade`, set by TabsList).\n * The mask's `#000` only means opaque: a gradient mask is read for its alpha (`mask-mode:\n * match-source`), so no color of it reaches the page, whatever the theme.\n *\n * @internal\n * @claim \"The mask's `#000` only means opaque\" https://developer.mozilla.org/en-US/docs/Web/CSS/mask-mode verify:urlOk(https://developer.mozilla.org/en-US/docs/Web/CSS/mask-mode)\n */\nconst listClass =\n  \"relative z-0 m-0 box-border flex shrink-0 p-0 \" +\n  \"data-[orientation=horizontal]:overflow-x-auto data-[orientation=horizontal]:[scrollbar-width:none] \" +\n  \"data-[orientation=horizontal]:shadow-[inset_0_-1px_0_0_var(--border)] \" +\n  \"data-[fade=right]:[mask-image:linear-gradient(to_right,#000_calc(100%-2rem),transparent)] \" + // fade-ok: fades the hidden end of a row of tabs, not a picture\n  \"data-[fade=left]:[mask-image:linear-gradient(to_left,#000_calc(100%-2rem),transparent)] \" + // fade-ok: fades the hidden end of a row of tabs, not a picture\n  \"data-[fade=both]:[mask-image:linear-gradient(to_right,transparent,#000_2rem,#000_calc(100%-2rem),transparent)] \" + // fade-ok: fades the hidden end of a row of tabs, not a picture\n  \"data-[orientation=vertical]:flex-col data-[orientation=vertical]:shadow-[inset_-1px_0_0_0_var(--border)] \" +\n  \"rtl:data-[orientation=vertical]:shadow-[inset_1px_0_0_0_var(--border)]\";\n\n/**\n * A tab: 44px tall with 16px text on a coarse pointer, stepping down to 36px and 14px from\n * `sm` with a fine pointer. The selected tab takes the foreground color, the others are\n * muted. The focus outline is inset, so the scrolling row never clips it. Under forced colours,\n * where the fill and the underline drop away, each tab draws a border, and the selected tab is\n * filled with Highlight and lettered in HighlightText. Hover lifts only the other tabs' text, so\n * the pointer resting on the selected tab never turns its letters back to the page's text colour.\n *\n * @internal\n * @claim \"Hover lifts only the other tabs'\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > keeps HighlightText on the selected tab under forced colours while the pointer rests on it)\n * @claim \"Under forced colours, where the fill\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > draws each tab's edge under forced colours, where its fill and the underline drop away)\n * @claim \"Under forced colours, where the fill\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > shows which tab is selected under forced colours: Highlight behind it and HighlightText on it)\n * @claim \"A tab: 44px tall with 16px\" registry/ouro/components/ouro/tabs/tabs.touch.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.touch.test.tsx::keeps 44px tabs with 16px text on a phone, also in landscape)\n * @claim \"The focus outline is inset, so\" registry/ouro/components/ouro/tabs/tabs-styles.ts verify:fileLine(registry/ouro/components/ouro/tabs/tabs-styles.ts, /outline-ring\\s-outline-offset-2\\sfocus-visible:outline-2/)\n */\nconst tabClass =\n  \"group/tab press relative m-0 box-border inline-flex shrink-0 cursor-pointer items-center gap-2 whitespace-nowrap \" +\n  \"h-(--ouro-tab-h) px-3 [--ouro-tab-h:calc(var(--spacing)*11)] sm:pointer-fine:[--ouro-tab-h:calc(var(--spacing)*9)] \" +\n  \"pointer-coarse:min-w-11 justify-center data-[orientation=vertical]:justify-start \" +\n  \"rounded-ouro-md border-0 bg-transparent text-base font-medium text-muted-foreground sm:pointer-fine:text-sm \" +\n  \"forced-colors:border forced-colors:border-solid \" +\n  \"select-none touch-manipulation [-webkit-tap-highlight-color:transparent] \" +\n  \"not-data-disabled:not-data-active:pointer-fine:hover:text-foreground data-active:text-foreground \" +\n  \"forced-colors:data-active:bg-[Highlight] forced-colors:data-active:text-[HighlightText] \" +\n  \"outline-ring -outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid \" +\n  \"data-disabled:cursor-not-allowed data-disabled:opacity-50\";\n\n/**\n * The label and icon inside a tab, which take the press scale. The tab itself never\n * scales, because Base UI's indicator measures the tab's bounding box and a scaled box\n * would put the indicator off the tab.\n *\n * @internal\n * @claim \"The tab itself never scales, because\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > slides the indicator with translate and resizes it with scale only, on the ease-in-out token in the base duration)\n * @claim \"The tab itself never scales, because\" registry/ouro/components/ouro/tabs/tabs-styles.ts verify:fileLine(registry/ouro/components/ouro/tabs/tabs-styles.ts, /motion-safe:group-not-data-disabled/tab:group-active/tab:scale-\\(--ouro-press-scale\\)/)\n */\nconst tabFaceClass =\n  \"inline-flex items-center gap-2 [transition:scale_var(--ouro-duration-press)_var(--ouro-ease-out)] \" +\n  \"motion-safe:group-not-data-disabled/tab:group-active/tab:scale-(--ouro-press-scale)\";\n\n/**\n * The line under the selected tab (beside it, in a column). It is 1px long and scaled to the\n * selected tab's width (a unitless factor from Base UI's length), so it slides with `translate`\n * and resizes with `scale`, both on the ease-in-out token, and nothing lays out again. It has\n * square ends because a scaled radius would distort. The line is never what Base UI measures,\n * and the tab never scales. With reduced motion, or while the keys move the selection, it\n * moves without a transition.\n *\n * @internal\n * @claim \"It is 1px long and scaled\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > slides the indicator with translate and resizes it with scale only, on the ease-in-out token in the base duration)\n * @claim \"It is 1px long and scaled\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > slides the indicator under the selected tab)\n * @claim \"It is 1px long and scaled\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > resizes the indicator between tabs of different width without ever changing its layout box, and keeps its ends square)\n * @claim \"The line is never what Base\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > slides the indicator with translate and resizes it with scale only, on the ease-in-out token in the base duration)\n * @claim \"The line is never what Base\" registry/ouro/components/ouro/tabs/tabs-styles.ts verify:fileLine(registry/ouro/components/ouro/tabs/tabs-styles.ts, /motion-safe:group-not-data-disabled/tab:group-active/tab:scale-\\(--ouro-press-scale\\)/)\n */\nconst indicatorClass =\n  \"pointer-events-none absolute z-1 bg-primary \" +\n  \"[transition-property:translate,scale] duration-(--ouro-duration-base) ease-(--ouro-ease-in-out) motion-reduce:transition-none in-data-ouro-keyboard:transition-none \" +\n  \"data-[orientation=horizontal]:bottom-0 data-[orientation=horizontal]:left-0 data-[orientation=horizontal]:h-0.5 \" +\n  \"data-[orientation=horizontal]:w-px data-[orientation=horizontal]:origin-left data-[orientation=horizontal]:translate-x-(--active-tab-left) \" +\n  \"data-[orientation=horizontal]:scale-x-[tan(atan2(var(--active-tab-width,0px),1px))] \" +\n  \"data-[orientation=vertical]:top-0 data-[orientation=vertical]:end-0 data-[orientation=vertical]:w-0.5 \" +\n  \"data-[orientation=vertical]:h-px data-[orientation=vertical]:origin-top data-[orientation=vertical]:translate-y-(--active-tab-top) \" +\n  \"data-[orientation=vertical]:scale-y-[tan(atan2(var(--active-tab-height,0px),1px))]\";\n\n/**\n * The list of links when the tabs are links: the tab row's look, without the list's bullets.\n *\n * @internal\n */\nconst linkListClass = \"list-none\";\n\n/**\n * One link's list item, which the link fills, so a column of links lines up on the hairline.\n *\n * @internal\n */\nconst linkItemClass = \"m-0 flex p-0\";\n\n/**\n * A tab that is a link: the tab's look, filling its list item, without the link's underline.\n *\n * @internal\n */\nconst tabLinkClass = \"flex-1 no-underline\";\n\n/**\n * The line under the current link (beside it, in a column). It is drawn inside the current\n * link, on the row's hairline, and stands still, since a link opens a page of its own.\n *\n * @internal\n */\nconst linkIndicatorClass =\n  \"pointer-events-none absolute z-1 bg-primary \" +\n  \"data-[orientation=horizontal]:inset-x-0 data-[orientation=horizontal]:bottom-0 data-[orientation=horizontal]:h-0.5 \" +\n  \"data-[orientation=vertical]:inset-y-0 data-[orientation=vertical]:end-0 data-[orientation=vertical]:w-0.5\";\n\n/**\n * A panel. It fades in when its tab is selected; the old panel leaves at once, so the\n * layout never holds two panels.\n *\n * @internal\n * @claim \"It fades in when its tab\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > switches by key without animating the indicator or the panel, and by pointer with both)\n */\nconst panelClass =\n  \"min-w-0 flex-1 rounded-ouro-md outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid \" +\n  \"transition-opacity duration-(--ouro-duration-base) ease-(--ouro-ease-out) data-starting-style:opacity-0 data-ending-style:transition-none in-data-ouro-keyboard:transition-none\";\n",
      "type": "registry:ui",
      "target": "@components/ouro/tabs/tabs-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/tabs/tabs.tsx",
      "content": "\"use client\";\n\nimport { useId, useState, 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 { currentTabHref } from \"@/registry/ouro/lib/ouro/current-path\";\nimport { devThrow } from \"@/registry/ouro/lib/ouro/dev\";\nimport { RouterLink } from \"@/registry/ouro/lib/ouro/router-link\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { useMediaQuery } from \"@/registry/ouro/lib/ouro/use-media-query\";\nimport {\n  TabsIndicator,\n  TabsLinkList,\n  TabsList,\n  TabsPanel,\n  TabsRootUnchecked,\n  TabsTab,\n} from \"@/registry/ouro/components/ouro/tabs/tabs-parts\";\nimport {\n  activations,\n  linkIndicatorClass,\n  linkItemClass,\n  orientations,\n  ownLook,\n  rootClass,\n  tabClass,\n  tabFaceClass,\n  tabLinkClass,\n  type TabsActivation,\n  type TabsOrientation,\n} from \"@/registry/ouro/components/ouro/tabs/tabs-styles\";\n\nexport type { TabsActivation, TabsOrientation } from \"@/registry/ouro/components/ouro/tabs/tabs-styles\";\n\n/** One tab and its panel. */\nexport interface TabsItem {\n  /** Identifies the tab: `value`, `defaultValue` and `onValueChange` use it. Unique within the tabs. */\n  value: string;\n  /** The tab's text. Keep it short: one or two words. */\n  label: ReactNode;\n  /** What the panel shows while this tab is selected. */\n  content: ReactNode;\n  /** Shows the tab but keeps it from being selected. */\n  disabled?: boolean | undefined;\n  /** Not set: a tab with a panel. Give every item an `href`, and no `content`, for tabs that are links. */\n  href?: never;\n}\n\n/** One tab that is a link to a page of its own. */\nexport interface TabsLinkItem {\n  /** Identifies the tab: `value` names the current one with it. Unique within the tabs. */\n  value: string;\n  /** The tab's text. Keep it short: one or two words. */\n  label: ReactNode;\n  /**\n   * The page the tab opens. Internal paths render through `OuroProvider`'s `linkComponent`\n   * (your router's link).\n   */\n  href: string;\n  /** Not set: the page at `href` is the tab's content. */\n  content?: never;\n  /** A link cannot be disabled. Leave the item out instead. */\n  disabled?: never;\n}\n\n/** Props for {@link Tabs}. Items with `content` make tabs with panels; items with `href`, tabs that are links. */\nexport interface TabsProps {\n  /**\n   * Names the tab list for screen readers (\"Recipe sections\"), or the nav of links. It is not\n   * shown: the tabs' own labels are the visible text.\n   */\n  label: string;\n  /**\n   * The tabs, in order: each with the panel it shows (`content`), or each a link to its own\n   * page (`href`). Links render as a `<nav>` of links named by `label`, and Tab moves between\n   * them as between any links.\n   *\n   * @claim \"The tabs, in order: each with\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > renders a labelled tab list with the first tab selected and its panel shown)\n   * @claim \"Links render as a `<nav>` of\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs as links > renders a named nav of links, marking the current page, with the tabs' look)\n   * @claim \"Links render as a `<nav>` of\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs as links > moves between the links with Tab, and leaves the arrow keys to the page)\n   */\n  items: readonly TabsItem[] | readonly TabsLinkItem[];\n  /**\n   * The selected tab's value, when you control it. Pair it with `onValueChange`. With links,\n   * the current page's value, when `currentPath` cannot tell; it wins over `currentPath`.\n   */\n  value?: string | undefined;\n  /** The tab selected first, when the component keeps its own state. Panels only. @default the first enabled item */\n  defaultValue?: string | undefined;\n  /** Called with the new tab's value when the person selects a tab. Panels only: a link opens its page. */\n  onValueChange?: ((value: string) => void) | undefined;\n  /**\n   * Links only: the path of the page being shown, from your router, with its query when the\n   * tabs differ by query (`location.pathname + location.search`). The link at that path whose\n   * parameters the path carries gets `aria-current=\"page\"` and the current look; with links at\n   * other paths, the longest one the path sits under (`/recipes` for `/recipes/12`).\n   * @claim \"The link at that path whose\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs as links > marks the tab for the current path, by its query when the tabs share a path)\n   */\n  currentPath?: string | undefined;\n  /**\n   * `horizontal` puts the tabs in a row above the panel; `vertical` in a column beside it,\n   * from the `sm` breakpoint (640px) up, and in a row on a phone. With panels, the arrow keys\n   * follow: left and right in a row, up and down in a column.\n   * @default \"horizontal\"\n   * @claim \"`horizontal` puts the tabs in a\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > puts vertical tabs in a row above the panel on a narrow screen)\n   * @claim \"`horizontal` puts the tabs in a\" registry/ouro/components/ouro/tabs/tabs.touch.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.touch.test.tsx::stacks vertical tabs in a row on a phone)\n   */\n  orientation?: TabsOrientation | (string & { 'Use \"horizontal\" or \"vertical\"': never }) | undefined;\n  /**\n   * How the keyboard selects a tab with a panel. `automatic` selects it as soon as the arrow\n   * keys focus it, which suits panels that show at once. `manual` moves focus only and waits\n   * for Enter or Space, for panels that load slowly.\n   * @default \"automatic\"\n   */\n  activation?: TabsActivation | (string & { 'Use \"automatic\" or \"manual\"': never }) | undefined;\n  /** Layout only: margins, width, grid placement (`mt-6`). Appearance classes warn in development. */\n  className?: string | undefined;\n  ref?: Ref<HTMLDivElement> | undefined;\n\n  /** Not a prop. Ouro UI uses `onValueChange`, which gets the tab's value: `<Tabs onValueChange={(value) => …}>`. */\n  onChange?: { 'Use <Tabs onValueChange={(value) => ...}>': never };\n  /** Not a prop. Ouro UI uses `activation`: `<Tabs activation=\"manual\">`. */\n  activateOnFocus?: { 'Use <Tabs activation=\"automatic\"> or activation=\"manual\"': never };\n  /** Not a prop. Ouro UI uses `items`: `<Tabs items={[{ value, label, content }]}>`. */\n  tabs?: { 'Use <Tabs items={[{ value, label, content }]}>': never };\n  /** Not a prop. Tabs that are links use `currentPath`: `<Tabs currentPath={pathname}>`. */\n  pathname?: { 'Use <Tabs currentPath={pathname}>': never };\n}\n\n/** The first value that appears twice, or undefined. Development only. */\nfunction duplicateValue(items: readonly { value: string }[]): string | undefined {\n  const seen = new Set<string>();\n  for (const item of items) {\n    if (seen.has(item.value)) return item.value;\n    seen.add(item.value);\n  }\n  return undefined;\n}\n\n/**\n * Tabs that switch between panels in place: an accessible tab list with roving focus,\n * arrow-key navigation, a line that slides to the selected tab, and\n * 44px tabs on touch screens. Pass the tabs and their panels as `items`.\n * Under forced colours (Windows contrast themes) each tab keeps a border and the selected one is filled with Highlight.\n *\n * When each tab is a view of one page with a URL of its own (a section's pages, a search's\n * scopes), give each item an `href` instead of `content`: the tabs render as a `<nav>` of\n * links in the same look, through your router's link, with the current one marked\n * `aria-current=\"page\"` from `currentPath`, and Tab moves between them as between any links.\n *\n * Use `SegmentedControl` instead when the choice changes how one view looks (list or grid)\n * rather than which content shows. Use `Navbar` or `Sidebar` instead for the site's own\n * navigation. Use the parts in `tabs-parts` when `items` cannot express your layout.\n * In a right-to-left page (`dir=\"rtl\"` on `<html>`) the arrow keys follow the row: ArrowLeft moves to the next tab.\n *\n *\n * @group Navigation\n * @claim \"In a right-to-left page\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > moves to the next tab with ArrowLeft in a right-to-left page, where it sits on the left)\n * @see https://ui.ouroboros.bot/docs/tabs\n *\n * @example\n * <Tabs\n *   label=\"Recipe\"\n *   items={[\n *     { value: \"ingredients\", label: \"Ingredients\", content: <IngredientList /> },\n *     { value: \"method\", label: \"Method\", content: <Steps /> },\n *   ]}\n * />\n * <Tabs\n *   label=\"Recipes\"\n *   currentPath={location.pathname}\n *   items={[\n *     { value: \"all\", label: \"All\", href: \"/recipes\" },\n *     { value: \"mine\", label: \"Mine\", href: \"/my-recipes\" },\n *   ]}\n * />\n * @claim \"Tabs that switch between panels in\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > renders a labelled tab list with the first tab selected and its panel shown)\n * @claim \"Tabs that switch between panels in\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > slides the indicator under the selected tab)\n * @claim \"Tabs that switch between panels in\" registry/ouro/components/ouro/tabs/tabs.touch.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.touch.test.tsx::keeps 44px tabs with 16px text on a phone, also in landscape)\n * @claim \"Under forced colours (Windows contrast\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > draws each tab's edge under forced colours, where its fill and the underline drop away)\n * @claim \"Under forced colours (Windows contrast\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs > shows which tab is selected under forced colours: Highlight behind it and HighlightText on it)\n * @claim \"When each tab is a view\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs as links > renders a named nav of links, marking the current page, with the tabs' look)\n * @claim \"When each tab is a view\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs as links > renders each link through the app's router link)\n * @claim \"When each tab is a view\" registry/ouro/components/ouro/tabs/tabs.test.tsx verify:testExists(registry/ouro/components/ouro/tabs/tabs.test.tsx::Tabs as links > moves between the links with Tab, and leaves the arrow keys to the page)\n */\nexport function Tabs(props: TabsProps): JSX.Element {\n  const {\n    label,\n    items,\n    value,\n    defaultValue,\n    onValueChange,\n    orientation: orientationProp = \"horizontal\",\n    activation: activationProp = \"automatic\",\n    currentPath,\n    className,\n    ref,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    onChange,\n    activateOnFocus,\n    tabs,\n    pathname,\n  } = props;\n  // An orientation or activation that is not one of Ouro UI's (a type error) warns and renders the default.\n  const orientation = orientations.includes(orientationProp as TabsOrientation) ? (orientationProp as TabsOrientation) : \"horizontal\";\n  const activation = activations.includes(activationProp as TabsActivation) ? (activationProp as TabsActivation) : \"automatic\";\n  useAppearanceClassNameCheck(\n    \"Tabs\",\n    className,\n    process.env.NODE_ENV !== \"production\" ? ownLook(\"Tabs\") : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  // Tabs that are links: every item has an href.\n  const links = items.length > 0 && items.every((item) => item.href !== undefined);\n  const duplicate = duplicateValue(items);\n  if (duplicate !== undefined) {\n    // Two tabs with one value would select together and loop Base UI's bookkeeping.\n    devThrow(\n      \"Tabs\",\n      `two items have the value \"${duplicate}\"`,\n      process.env.NODE_ENV !== \"production\" ? \"give each item its own value\" : /* istanbul ignore next @preserve -- production only */ \"\",\n    );\n  }\n  useDevWarnings(\n    \"Tabs\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => {\n          const known = (candidate: string | undefined) => candidate === undefined || items.some((item) => item.value === candidate);\n          const first = items[0]?.value ?? \"…\";\n          return [\n            orientation !== orientationProp && [\n              `orientation=\"${String(orientationProp)}\" is not an orientation; use ${orientations.map((name) => `\"${name}\"`).join(\", \")}`,\n              '<Tabs orientation=\"horizontal\">',\n            ],\n            activation !== activationProp && [\n              `activation=\"${String(activationProp)}\" is not an activation; use ${activations.map((name) => `\"${name}\"`).join(\", \")}`,\n              '<Tabs activation=\"automatic\">',\n            ],\n            onChange !== undefined && [\"onChange is not a prop\", \"<Tabs onValueChange={(value) => …}>\"],\n            activateOnFocus !== undefined && [\n              \"activateOnFocus is not a prop\",\n              `<Tabs activation=\"${activateOnFocus === (false as unknown) ? \"manual\" : \"automatic\"}\">`,\n            ],\n            tabs !== undefined && [\"tabs is not a prop\", \"<Tabs items={[{ value, label, content }]}>\"],\n            pathname !== undefined && [\"pathname is not a prop\", \"<Tabs currentPath={pathname}>\"],\n            !known(defaultValue) && [`defaultValue=\"${defaultValue}\" matches no item`, `<Tabs defaultValue=\"${first}\">`],\n            !known(value) && [`value=\"${value}\" matches no item`, `<Tabs value=\"${first}\">`],\n            ...(links\n              ? (\n                  [\n                    [\"defaultValue\", defaultValue],\n                    [\"onValueChange\", onValueChange],\n                    [\"activation\", props.activation],\n                  ] as const\n                ).map(([name, given]) => given !== undefined && [`${name} does nothing when the tabs are links`, \"<Tabs currentPath={pathname}>\"] as const)\n              : [currentPath !== undefined && ([\"currentPath marks a link, and these tabs have panels\", '<Tabs value=\"…\">'] as const)]),\n            !links &&\n              items.some((item) => item.href !== undefined) && [\n                \"some items have an href and some do not, so they render as panels\",\n                '<Tabs items={[{ value: \"…\", label: \"…\", href: \"/…\" }]}> for links, or { value, label, content } for panels',\n              ],\n          ];\n        }\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  // A column of tabs squeezes the panel on a phone: below the sm breakpoint it becomes a row.\n  // Wide in server HTML, so a desktop page does not shift.\n  const wide = useMediaQuery(\"(min-width: 640px)\", true);\n  const shown = orientation === \"vertical\" && !wide ? \"horizontal\" : orientation;\n  // Start on the first enabled tab, also in server HTML, where Base UI cannot see which tabs are disabled.\n  const [own, setOwn] = useState(() => defaultValue ?? items.find((item) => !item.disabled)?.value ?? null);\n  const selected = value !== undefined ? value : own;\n  // Ids from useId, so the tab and its panel name each other in server HTML too (Base UI\n  // links them only after it mounts). Only the selected panel is mounted, so only the\n  // selected tab points at one.\n  const id = useId();\n  if (links) {\n    const linkItems = items as readonly TabsLinkItem[];\n    const marked = currentTabHref(\n      linkItems.map((item) => item.href),\n      currentPath,\n    );\n    const current = value ?? linkItems.find((item) => item.href === marked)?.value;\n    return (\n      <div ref={ref} data-ouro=\"tabs\" data-orientation={shown} className={cn(rootClass, className)}>\n        <nav aria-label={label} className=\"min-w-0\">\n          <TabsLinkList orientation={shown} current={current}>\n            {linkItems.map((item) => {\n              const here = item.value === current;\n              return (\n                <li key={item.value} className={linkItemClass}>\n                  <RouterLink\n                    href={item.href}\n                    aria-current={here ? \"page\" : undefined}\n                    data-ouro-control=\"tabs\"\n                    data-ouro-part=\"link\"\n                    data-orientation={shown}\n                    data-active={here ? \"\" : undefined}\n                    className={cn(tabClass, tabLinkClass)}\n                  >\n                    <span className={tabFaceClass}>{item.label}</span>\n                    {here && <span aria-hidden=\"true\" data-ouro-tabs-indicator=\"\" data-orientation={shown} className={linkIndicatorClass} />}\n                  </RouterLink>\n                </li>\n              );\n            })}\n          </TabsLinkList>\n        </nav>\n      </div>\n    );\n  }\n  return (\n    <TabsRootUnchecked\n      ref={ref}\n      orientation={shown}\n      value={selected}\n      onValueChange={(next: string) => {\n        setOwn(next);\n        onValueChange?.(next);\n      }}\n      className={className}\n    >\n      <TabsList aria-label={label} activateOnFocus={activation === \"automatic\"}>\n        {items.map((item, index) => (\n          <TabsTab\n            key={item.value}\n            value={item.value}\n            disabled={item.disabled}\n            id={`${id}tab${index}`}\n            aria-controls={item.value === selected ? `${id}panel${index}` : undefined}\n          >\n            {item.label}\n          </TabsTab>\n        ))}\n        <TabsIndicator />\n      </TabsList>\n      {items.map((item, index) => (\n        <TabsPanel key={item.value} value={item.value} id={`${id}panel${index}`} aria-labelledby={`${id}tab${index}`}>\n          {item.content}\n        </TabsPanel>\n      ))}\n    </TabsRootUnchecked>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/tabs/tabs.tsx"
    }
  ],
  "docs": "Tabs that switch between panels in place: an accessible tab list with roving focus, arrow-key navigation, a line that slides to the selected tab, and 44px tabs on touch screens. Import: import { Tabs } from \"@/components/ouro/tabs/tabs\", 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/tabs.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}