{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "opentui/tabbed-content",
  "title": "Tabbed Content",
  "description": "Tab bar wired to content panels",
  "dependencies": [
    "@opentui/react"
  ],
  "registryDependencies": [
    "https://termcn.dev/r/opentui/use-theme.json"
  ],
  "files": [
    {
      "path": "registry/opentui/ui/tabbed-content.tsx",
      "content": "/* @jsxImportSource @opentui/react */\nimport { useKeyboard } from \"@opentui/react\";\nimport { useState } from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { useTheme } from \"@/hooks/use-theme\";\n\nexport interface TabbedContentTab {\n  id: string;\n  label: string;\n  content: ReactNode;\n  disabled?: boolean;\n}\n\nexport interface TabbedContentProps {\n  tabs: TabbedContentTab[];\n  defaultTab?: string;\n  activeTab?: string;\n  onChange?: (id: string) => void;\n  tabBarStyle?: \"underline\" | \"box\" | \"minimal\";\n}\n\nexport const TabbedContent = ({\n  tabs,\n  defaultTab,\n  activeTab: controlledTab,\n  onChange,\n  tabBarStyle = \"underline\",\n}: TabbedContentProps) => {\n  const theme = useTheme();\n  const [internalTab, setInternalTab] = useState(\n    defaultTab ?? tabs[0]?.id ?? \"\"\n  );\n  const activeId = controlledTab ?? internalTab;\n  const activeIndex = tabs.findIndex((t) => t.id === activeId);\n\n  const switchTab = (id: string) => {\n    if (onChange) {\n      onChange(id);\n    } else {\n      setInternalTab(id);\n    }\n  };\n\n  useKeyboard((key) => {\n    if (key.name === \"left\" || (key.shift && key.name === \"tab\")) {\n      let prev = activeIndex - 1;\n      while (prev >= 0 && tabs[prev]?.disabled) {\n        prev -= 1;\n      }\n      if (prev >= 0) {\n        switchTab(tabs[prev].id);\n      }\n    } else if (key.name === \"right\" || key.name === \"tab\") {\n      let next = activeIndex + 1;\n      while (next < tabs.length && tabs[next]?.disabled) {\n        next += 1;\n      }\n      if (next < tabs.length) {\n        switchTab(tabs[next].id);\n      }\n    }\n  });\n\n  const activeTab = tabs.find((t) => t.id === activeId);\n\n  const renderTabBar = () => {\n    if (tabBarStyle === \"box\") {\n      return (\n        <box borderStyle=\"single\" borderColor={theme.colors.border}>\n          {tabs.map((tab, idx) => {\n            const isActive = tab.id === activeId;\n            let textColor: string;\n            if (tab.disabled) {\n              textColor = theme.colors.mutedForeground;\n            } else if (isActive) {\n              textColor = theme.colors.primary;\n            } else {\n              textColor = theme.colors.foreground;\n            }\n            return (\n              <box key={tab.id} paddingLeft={1} paddingRight={1}>\n                <text fg={textColor}>\n                  {isActive ? <b>{`[${tab.label}]`}</b> : ` ${tab.label} `}\n                </text>\n                {idx < tabs.length - 1 && (\n                  <text fg={theme.colors.border}>{\" │ \"}</text>\n                )}\n              </box>\n            );\n          })}\n        </box>\n      );\n    }\n\n    if (tabBarStyle === \"minimal\") {\n      return (\n        <box gap={2}>\n          {tabs.map((tab) => {\n            const isActive = tab.id === activeId;\n            let textColor: string;\n            if (tab.disabled) {\n              textColor = theme.colors.mutedForeground;\n            } else if (isActive) {\n              textColor = theme.colors.primary;\n            } else {\n              textColor = theme.colors.mutedForeground;\n            }\n            return (\n              <text key={tab.id} fg={textColor}>\n                {isActive ? <b>{tab.label}</b> : tab.label}\n              </text>\n            );\n          })}\n        </box>\n      );\n    }\n\n    return (\n      <box>\n        {tabs.map((tab, idx) => {\n          const isActive = tab.id === activeId;\n          let textColor: string;\n          if (tab.disabled) {\n            textColor = theme.colors.mutedForeground;\n          } else if (isActive) {\n            textColor = theme.colors.primary;\n          } else {\n            textColor = theme.colors.foreground;\n          }\n          return (\n            <box key={tab.id}>\n              <text fg={textColor}>\n                {isActive ? (\n                  <b>\n                    <u>{tab.label}</u>\n                  </b>\n                ) : (\n                  tab.label\n                )}\n              </text>\n              {idx < tabs.length - 1 && (\n                <text fg={theme.colors.border}>{\" │ \"}</text>\n              )}\n            </box>\n          );\n        })}\n      </box>\n    );\n  };\n\n  return (\n    <box flexDirection=\"column\">\n      {renderTabBar()}\n      <box\n        borderStyle=\"single\"\n        borderColor={theme.colors.border}\n        paddingLeft={1}\n        paddingRight={1}\n        marginTop={0}\n      >\n        {activeTab?.content}\n      </box>\n      <text fg=\"#666\">←→ or Tab to switch tabs</text>\n    </box>\n  );\n};\n",
      "type": "registry:ui",
      "target": "components/ui/tabbed-content.tsx"
    }
  ],
  "categories": [
    "navigation"
  ],
  "type": "registry:ui"
}