{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tabs",
  "type": "registry:ui",
  "title": "Tabs",
  "description": "Underline and pill tab variants built on React Aria.",
  "dependencies": [
    "react-aria-components@^1.17.0"
  ],
  "registryDependencies": [
    "cx",
    "direction"
  ],
  "files": [
    {
      "path": "components/base/tabs/pill-tab.tsx",
      "content": "\"use client\";\n\nimport { useDirection } from \"@/components/foundations/direction/direction\";\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentType, HTMLAttributes, ReactNode, Ref } from \"react\";\nimport { cx, sortCx } from \"@/utils/cx\";\n\nconst useIsomorphicLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/**\n * Figma source: Board UI → \"ai_chat\" → Changes / Browser panel switcher\n * (node 4030:5993 region) — the fully-rounded pill tab, in two styles:\n *\n *   pill      px 8, py 5, gap 4\n *   blue      fully rounded (40px); selected bg uses the semantic blue pill\n *             surface, icon + label color/blue/500 (the AI chat panel switcher)\n *   gray      radius/2lg (10px); selected bg background/tertiary, label\n *             text/primary (quieter — scope/filter rows like the settings\n *             Tools page)\n *   idle      label text/secondary, icon foreground/icon/secondary,\n *             background/primary/hover on hover (both styles)\n *   icon      optional 20px leading glyph\n *\n * `PillTabList` owns the animated selection background so it can slide\n * between pills with a subtle spring-like settle. `PillTab` remains a plain\n * button (not a React Aria Tabs collection): these switchers drive local view\n * state, not routed tab panels.\n */\n\ntype IconComponent = ComponentType<{\n  className?: string;\n  \"aria-hidden\"?: boolean | \"true\" | \"false\";\n}>;\n\nexport type PillTabVariant = \"blue\" | \"gray\";\n\nconst styles = sortCx({\n  radius: {\n    blue: \"rounded-full\",\n    gray: \"rounded-2lg\",\n  },\n  thumb: {\n    blue: \"bg-pill-tab-blue-selected-background\",\n    gray: \"bg-background-tertiary-default\",\n  },\n  hover: {\n    blue: \"bg-pill-tab-blue-hover-background\",\n    gray: \"bg-background-primary-hover\",\n  },\n  selectedIcon: {\n    blue: \"text-accent-500\",\n    gray: \"text-foreground-icon-primary\",\n  },\n  selectedLabel: {\n    blue: \"text-accent-500\",\n    gray: \"text-text-primary\",\n  },\n});\n\ntype Thumb = {\n  left: number;\n  top: number;\n  width: number;\n  height: number;\n  variant: PillTabVariant;\n};\n\nexport interface PillTabListProps extends HTMLAttributes<HTMLDivElement> {\n  ref?: Ref<HTMLDivElement>;\n}\n\nexport function PillTabList({ children, className, ref, ...props }: PillTabListProps) {\n  const direction = useDirection();\n  const innerRef = useRef<HTMLDivElement>(null);\n  const [thumb, setThumb] = useState<Thumb | null>(null);\n\n  useIsomorphicLayoutEffect(() => {\n    const el = innerRef.current;\n    if (!el) return;\n    const measure = () => {\n      const selected = el.querySelector<HTMLElement>(\"[data-pill-selected]\");\n      if (!selected) return;\n      setThumb({\n        left: selected.offsetLeft,\n        top: selected.offsetTop,\n        width: selected.offsetWidth,\n        height: selected.offsetHeight,\n        variant: selected.dataset.pillVariant === \"gray\" ? \"gray\" : \"blue\",\n      });\n    };\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(el);\n    const observeTabs = () => el.querySelectorAll(\"button\").forEach(tab => ro.observe(tab));\n    observeTabs();\n    const mo = new MutationObserver(() => { observeTabs(); measure(); });\n    mo.observe(el, {\n      attributes: true,\n      childList: true,\n      characterData: true,\n      subtree: true,\n      attributeFilter: [\"data-pill-selected\"],\n    });\n    return () => {\n      mo.disconnect();\n      ro.disconnect();\n    };\n  }, [direction]);\n\n  const setRefs = (node: HTMLDivElement | null) => {\n    innerRef.current = node;\n    if (typeof ref === \"function\") ref(node);\n    else if (ref) (ref as { current: HTMLDivElement | null }).current = node;\n  };\n\n  return (\n    <div\n      ref={setRefs}\n      role=\"group\"\n      className={cx(\"relative inline-flex items-center gap-1\", className)}\n      {...props}\n    >\n      {thumb && (\n        <span\n          aria-hidden\n          className={cx(\n            \"pointer-events-none absolute left-0 top-0\",\n            \"transition-[transform,width,height] duration-300\",\n            \"[transition-timing-function:cubic-bezier(0.34,1.2,0.64,1)]\",\n            styles.radius[thumb.variant],\n            styles.thumb[thumb.variant],\n          )}\n          style={{\n            transform: `translate(${thumb.left}px, ${thumb.top}px)`,\n            width: thumb.width,\n            height: thumb.height,\n          }}\n        />\n      )}\n      {children}\n    </div>\n  );\n}\n\nexport function PillTab({\n  variant = \"blue\",\n  icon: Icon,\n  isSelected,\n  onSelect,\n  children,\n  className,\n}: {\n  variant?: PillTabVariant;\n  icon?: IconComponent;\n  isSelected: boolean;\n  onSelect: () => void;\n  children: ReactNode;\n  className?: string;\n}) {\n  return (\n    <button\n      type=\"button\"\n      aria-pressed={isSelected}\n      data-pill-selected={isSelected ? \"\" : undefined}\n      data-pill-variant={variant}\n      onClick={onSelect}\n      className={cx(\n        \"group relative z-10 flex shrink-0 cursor-pointer items-center gap-1 px-2 py-[5px]\",\n        styles.radius[variant],\n        \"outline-none transition-colors duration-150 ease\",\n        \"focus-visible:ring-2 focus-visible:ring-border-focus-ring\",\n        className,\n      )}\n    >\n      <span\n        aria-hidden\n        className={cx(\n          \"pointer-events-none absolute inset-0 opacity-0\",\n          \"transition-opacity duration-200 ease-out\",\n          styles.radius[variant],\n          styles.hover[variant],\n          !isSelected && \"group-hover:opacity-100\",\n        )}\n      />\n      {Icon && (\n        <Icon\n          className={cx(\n            \"relative z-10 size-5 shrink-0\",\n            isSelected ? styles.selectedIcon[variant] : \"text-foreground-icon-secondary\",\n          )}\n          aria-hidden\n        />\n      )}\n      <span\n        className={cx(\n          \"relative z-10 text-body-medium whitespace-nowrap\",\n          isSelected ? styles.selectedLabel[variant] : \"text-text-secondary\",\n        )}\n      >\n        {children}\n      </span>\n    </button>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/base/tabs/pill-tab.tsx"
    },
    {
      "path": "components/base/tabs/tabs.tsx",
      "content": "\"use client\";\n\nimport { useDirection } from \"@/components/foundations/direction/direction\";\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ComponentType, ReactNode, Ref } from \"react\";\nimport {\n  Tab as AriaTab,\n  TabList as AriaTabList,\n  TabPanel as AriaTabPanel,\n  Tabs as AriaTabs,\n} from \"react-aria-components\";\nimport type {\n  TabListProps as AriaTabListProps,\n  TabPanelProps as AriaTabPanelProps,\n  TabProps as AriaTabProps,\n  TabsProps as AriaTabsProps,\n} from \"react-aria-components\";\nimport { cx } from \"@/utils/cx\";\n\nconst useIsomorphicLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/**\n * Figma source: Board UI → Tab (node 3793:2942).\n *\n * Underline tabs. The tab strip sits on a 1px border/button/default baseline;\n * the active tab paints a 2px color/blue/600 underline over it.\n *   tab       px 10, py 8, gap 10 (label ↔ count), Body 1 (14/20)\n *     active     text color/blue/600, Medium weight, 2px blue underline\n *     inactive   text/primary, Regular weight, transparent underline\n *   count     radius/sm, px 4, py 1, Caption 1/Medium (12/16)\n *     active     bg color/blue/100, text color/blue/600\n *     inactive   bg black/10 @ 50% opacity, text/primary\n *   icon      optional 16px leading glyph, inherits the label color\n *\n * Built on react-aria Tabs: roving-tabindex arrow-key navigation, automatic\n * activation, and TabList/TabPanel association.\n */\n\ntype IconComponent = ComponentType<{\n  className?: string;\n  \"aria-hidden\"?: boolean | \"true\" | \"false\";\n}>;\n\nexport interface TabsProps extends AriaTabsProps {\n  ref?: Ref<HTMLDivElement>;\n}\n\nexport function Tabs({ className, ref, ...props }: TabsProps) {\n  return (\n    <AriaTabs\n      ref={ref}\n      {...props}\n      className={(state) =>\n        cx(\n          \"flex w-full flex-col gap-4\",\n          state.orientation === \"vertical\" && \"flex-row\",\n          typeof className === \"function\" ? className(state) : className,\n        )\n      }\n    />\n  );\n}\n\nexport interface TabListProps<T extends object> extends AriaTabListProps<T> {\n  ref?: Ref<HTMLDivElement>;\n}\n\ntype Underline = { left: number; width: number };\n\nexport function TabList<T extends object>({ className, ref, ...props }: TabListProps<T>) {\n  const direction = useDirection();\n  const wrapperRef = useRef<HTMLDivElement>(null);\n  const [underline, setUnderline] = useState<Underline | null>(null);\n\n  useIsomorphicLayoutEffect(() => {\n    const el = wrapperRef.current;\n    if (!el) return;\n    const measure = () => {\n      const selected = el.querySelector<HTMLElement>(\"[role='tab'][data-selected]\");\n      if (selected) {\n        setUnderline({ left: selected.offsetLeft, width: selected.offsetWidth });\n      }\n    };\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(el);\n    // Labels and fonts can change width without resizing the full tab strip.\n    const observeTabs = () => el.querySelectorAll(\"[role='tab']\").forEach(tab => ro.observe(tab));\n    observeTabs();\n    const mo = new MutationObserver(() => { observeTabs(); measure(); });\n    mo.observe(el, { attributes: true, childList: true, characterData: true, subtree: true, attributeFilter: [\"data-selected\"] });\n    return () => {\n      mo.disconnect();\n      ro.disconnect();\n    };\n  }, [direction]);\n\n  return (\n    <div ref={wrapperRef} className=\"relative w-full\">\n      <AriaTabList\n        ref={ref}\n        {...props}\n        className={(state) =>\n          cx(\n            \"flex w-full items-center gap-1 border-b border-separator-border\",\n            typeof className === \"function\" ? className(state) : className,\n          )\n        }\n      />\n      {underline && (\n        <span\n          aria-hidden\n          className=\"pointer-events-none absolute bottom-0 left-0 h-0.5 bg-accent-600 transition-[transform,width] duration-200 ease\"\n          style={{\n            transform: `translateX(${underline.left}px)`,\n            width: underline.width,\n          }}\n        />\n      )}\n    </div>\n  );\n}\n\nexport interface TabProps extends Omit<AriaTabProps, \"children\"> {\n  children?: ReactNode;\n  /** Optional leading icon (16px). Inherits the label color. */\n  icon?: IconComponent;\n  /** Optional trailing count badge. */\n  count?: ReactNode;\n  ref?: Ref<HTMLDivElement>;\n}\n\nexport function Tab({ className, children, icon: Icon, count, ref, ...props }: TabProps) {\n  return (\n    <AriaTab\n      ref={ref}\n      {...props}\n      className={(state) =>\n        cx(\n          \"relative inline-flex cursor-pointer items-center gap-2.5 px-2.5 py-2 whitespace-nowrap\",\n          \"outline-none transition-colors duration-150 ease\",\n          \"focus-visible:rounded-sm focus-visible:ring-2 focus-visible:ring-border-focus-ring\",\n          state.isDisabled && \"cursor-not-allowed opacity-50\",\n          typeof className === \"function\" ? className(state) : className,\n        )\n      }\n    >\n      {({ isSelected }) => (\n        <>\n          <span\n            className={cx(\n              \"inline-flex items-center gap-1.5\",\n              isSelected\n                ? \"text-body-medium text-accent-600\"\n                : \"text-body-regular text-text-primary\",\n            )}\n          >\n            {Icon && <Icon className=\"size-4 shrink-0\" aria-hidden />}\n            {children}\n          </span>\n          {count != null && (\n            <span\n              className={cx(\n                \"inline-flex items-center justify-center rounded-sm px-1 py-px text-caption-1-medium whitespace-nowrap\",\n                isSelected\n                  ? \"bg-tab-count-selected-background text-accent-600\"\n                  : \"bg-black/10 text-text-primary opacity-50\",\n              )}\n            >\n              {count}\n            </span>\n          )}\n        </>\n      )}\n    </AriaTab>\n  );\n}\n\nexport interface TabPanelProps extends AriaTabPanelProps {\n  ref?: Ref<HTMLDivElement>;\n}\n\nexport function TabPanel({ className, ref, ...props }: TabPanelProps) {\n  return (\n    <AriaTabPanel\n      ref={ref}\n      {...props}\n      className={(state) =>\n        cx(\n          \"outline-none focus-visible:rounded-sm focus-visible:ring-2 focus-visible:ring-border-focus-ring\",\n          typeof className === \"function\" ? className(state) : className,\n        )\n      }\n    />\n  );\n}\n",
      "type": "registry:component",
      "target": "components/base/tabs/tabs.tsx"
    }
  ],
  "meta": {
    "docsUrl": "https://www.boardui.com/components/tabs",
    "example": "import { RiImage2Line, RiArticleLine } from \"@remixicon/react\";\nimport { Tab, TabList, TabPanel, Tabs } from \"@/components/base/tabs/tabs\";\n\nexport function Example() {\n  return (\n    <Tabs defaultSelectedKey=\"banners\">\n      <TabList aria-label=\"Content types\">\n        <Tab id=\"banners\" icon={RiImage2Line} count={152}>\n          Banners\n        </Tab>\n        <Tab id=\"posts\" icon={RiArticleLine} count={32}>\n          Posts\n        </Tab>\n        <Tab id=\"settings\">Settings</Tab>\n      </TabList>\n\n      <TabPanel id=\"banners\" />\n      <TabPanel id=\"posts\" />\n      <TabPanel id=\"settings\" />\n    </Tabs>\n  );\n}"
  }
}
