{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "side-tab-menu",
  "title": "Side Tab Menu",
  "description": "A vertical tab menu for settings pages: tabs with icons, second-line descriptions and count badges, grouped under headings, an active highlight with a rail that slides between them, and a panel that fades to the chosen tab. Stacks on phones.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/side-tab-menu/side-tab-menu.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface SideTab {\n  id: string;\n  label: string;\n  icon?: React.ReactNode;\n  /** A second line under the label. */\n  description?: string;\n  /** A count on the right, like unread items. */\n  badge?: number;\n  /** Tabs with the same group are listed under that heading. */\n  group?: string;\n  disabled?: boolean;\n  /** What the panel shows when this tab is active. */\n  content?: React.ReactNode;\n}\n\nexport interface SideTabMenuProps {\n  tabs: SideTab[];\n  value?: string;\n  defaultValue?: string;\n  onValueChange?: (id: string) => void;\n  /** Width of the tab column. */\n  menuWidth?: number;\n  /** Hide descriptions to make the menu compact. */\n  compact?: boolean;\n  /** Render the panel next to the menu (tabs with content). Off: just the menu. */\n  showPanel?: boolean;\n  label?: string;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.55)\", faint: \"rgba(245,244,241,0.35)\", active: \"rgba(255,255,255,0.07)\", hover: \"rgba(255,255,255,0.04)\", rail: \"#F5F4F1\", border: \"rgba(255,255,255,0.1)\", panel: \"#0E0E0E\", badge: \"rgba(255,255,255,0.1)\", focus: \"rgba(245,244,241,0.85)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.55)\", faint: \"rgba(10,10,10,0.38)\", active: \"rgba(10,10,10,0.06)\", hover: \"rgba(10,10,10,0.035)\", rail: \"#0A0A0A\", border: \"rgba(10,10,10,0.1)\", panel: \"#FFFFFF\", badge: \"rgba(10,10,10,0.07)\", focus: \"rgba(10,10,10,0.85)\" },\n};\n\nexport function SideTabMenu({ tabs, value, defaultValue, onValueChange, menuWidth = 232, compact = false, showPanel = true, label = \"Settings\", theme = \"dark\", className }: SideTabMenuProps) {\n  const p = PALETTES[theme];\n  const uid = React.useId();\n  const reduce = Boolean(useReducedMotion());\n  const firstEnabled = tabs.find((t) => !t.disabled)?.id;\n  const [internal, setInternal] = React.useState(defaultValue ?? firstEnabled);\n  const current = value ?? internal;\n  const refs = React.useRef<Record<string, HTMLButtonElement | null>>({});\n  const enabled = tabs.filter((t) => !t.disabled);\n  const spring = reduce ? { duration: 0 } : { type: \"spring\" as const, stiffness: 520, damping: 40 };\n\n  const select = (id: string) => {\n    if (value === undefined) setInternal(id);\n    onValueChange?.(id);\n  };\n\n  const onKey = (e: React.KeyboardEvent, id: string) => {\n    const i = enabled.findIndex((t) => t.id === id);\n    const map: Record<string, number> = { ArrowDown: (i + 1) % enabled.length, ArrowUp: (i - 1 + enabled.length) % enabled.length, Home: 0, End: enabled.length - 1 };\n    if (!(e.key in map)) return;\n    e.preventDefault();\n    const next = enabled[map[e.key]];\n    refs.current[next.id]?.focus();\n    select(next.id);\n  };\n\n  // Keep the tabs in their given order, starting a new heading whenever the group changes.\n  const sections: { group?: string; items: SideTab[] }[] = [];\n  for (const t of tabs) {\n    const last = sections[sections.length - 1];\n    if (last && last.group === t.group) last.items.push(t);\n    else sections.push({ group: t.group, items: [t] });\n  }\n  const active = tabs.find((t) => t.id === current);\n\n  return (\n    // Side by side from the sm breakpoint; stacked (menu on top) on phones.\n    <div className={cn(\"flex w-full flex-col sm:flex-row\", className)} style={{ gap: showPanel ? 20 : 0, fontFamily: \"Inter, sans-serif\", color: p.text }}>\n      <nav aria-label={label} className=\"w-full shrink-0 sm:w-[var(--st-w)]\" style={{ [\"--st-w\" as string]: `${menuWidth}px` }}>\n        <div role=\"tablist\" aria-orientation=\"vertical\" aria-label={label} className=\"flex flex-col\" style={{ gap: 2 }}>\n          {sections.map((sec, si) => (\n            <React.Fragment key={`${sec.group ?? \"none\"}-${si}`}>\n              {sec.group && (\n                <p className=\"text-[11px] font-semibold tracking-wider uppercase\" style={{ color: p.faint, padding: si === 0 ? \"0 12px 6px\" : \"14px 12px 6px\" }}>\n                  {sec.group}\n                </p>\n              )}\n              {sec.items.map((t) => {\n                const on = t.id === current;\n                return (\n                  <button\n                    key={t.id}\n                    ref={(el) => {\n                      refs.current[t.id] = el;\n                    }}\n                    type=\"button\"\n                    role=\"tab\"\n                    id={`${uid}-tab-${t.id}`}\n                    aria-selected={on}\n                    aria-controls={showPanel ? `${uid}-panel` : undefined}\n                    tabIndex={on ? 0 : -1}\n                    disabled={t.disabled}\n                    onClick={() => select(t.id)}\n                    onKeyDown={(e) => onKey(e, t.id)}\n                    className={cn(\"group/tab relative flex w-full cursor-pointer items-center text-left outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-40\", !on && \"hover:bg-[var(--st-hover)]\")}\n                    style={{ gap: 11, padding: compact ? \"8px 12px\" : \"10px 12px\", borderRadius: 10, [\"--st-hover\" as string]: p.hover, [\"--tw-ring-color\" as string]: p.focus }}\n                  >\n                    {on && (\n                      <motion.span layoutId={`${uid}-active`} aria-hidden=\"true\" className=\"absolute inset-0\" style={{ borderRadius: 10, background: p.active }} transition={spring}>\n                        <span className=\"absolute top-1/2 left-0 -translate-y-1/2 rounded-full\" style={{ width: 3, height: \"56%\", background: p.rail }} />\n                      </motion.span>\n                    )}\n                    {t.icon && (\n                      <span className=\"relative flex shrink-0 [&>svg]:h-full [&>svg]:w-full\" style={{ width: 18, height: 18, color: on ? p.text : p.muted, transition: \"color 0.15s ease\" }}>\n                        {t.icon}\n                      </span>\n                    )}\n                    <span className=\"relative flex min-w-0 flex-1 flex-col\" style={{ gap: 1 }}>\n                      <span className=\"truncate text-[13.5px] font-medium\" style={{ color: on ? p.text : p.muted, transition: \"color 0.15s ease\" }}>\n                        {t.label}\n                      </span>\n                      {!compact && t.description && (\n                        <span className=\"truncate text-[12px]\" style={{ color: p.faint }}>\n                          {t.description}\n                        </span>\n                      )}\n                    </span>\n                    {t.badge !== undefined && t.badge > 0 && (\n                      <span className=\"relative shrink-0 rounded-full text-[11px] font-semibold tabular-nums\" style={{ padding: \"1px 7px\", background: p.badge, color: p.text }}>\n                        {t.badge}\n                      </span>\n                    )}\n                  </button>\n                );\n              })}\n            </React.Fragment>\n          ))}\n        </div>\n      </nav>\n      {showPanel && (\n        <div id={`${uid}-panel`} role=\"tabpanel\" aria-labelledby={active ? `${uid}-tab-${active.id}` : undefined} tabIndex={0} className=\"relative min-w-0 flex-1 overflow-hidden outline-none focus-visible:ring-2\" style={{ borderRadius: 16, border: `1px solid ${p.border}`, background: p.panel, [\"--tw-ring-color\" as string]: p.focus }}>\n          <AnimatePresence mode=\"wait\" initial={false}>\n            <motion.div key={current} initial={reduce ? false : { opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0, y: -6 }} transition={{ duration: 0.2, ease: \"easeOut\" }} style={{ padding: 20 }}>\n              {active?.content}\n            </motion.div>\n          </AnimatePresence>\n        </div>\n      )}\n    </div>\n  );\n}\n\nconst svg = { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", stroke: \"currentColor\", strokeWidth: 1.7, strokeLinecap: \"round\" as const, strokeLinejoin: \"round\" as const, \"aria-hidden\": true };\nconst I = {\n  user: <svg {...svg}><circle cx=\"12\" cy=\"8\" r=\"4\" /><path d=\"M4.5 20.5a7.5 7.5 0 0 1 15 0\" /></svg>,\n  bell: <svg {...svg}><path d=\"M5 17h14l-1.4-2a3.2 3.2 0 0 1-.6-1.9V10a5 5 0 0 0-10 0v3.1a3.2 3.2 0 0 1-.6 1.9ZM10 20a2.2 2.2 0 0 0 4 0\" /></svg>,\n  card: <svg {...svg}><rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2.5\" /><path d=\"M3 10h18M7 15h3\" /></svg>,\n  shield: <svg {...svg}><path d=\"M12 21s7-3.3 7-9V5.8a1 1 0 0 0-.7-1L12.4 3a1.3 1.3 0 0 0-.8 0L5.7 4.8a1 1 0 0 0-.7 1V12c0 5.7 7 9 7 9Z\" /></svg>,\n  plug: <svg {...svg}><path d=\"M9 2.5V7M15 2.5V7M6 7h12v4a6 6 0 0 1-12 0ZM12 17v4.5\" /></svg>,\n  users: <svg {...svg}><circle cx=\"9\" cy=\"8\" r=\"3.5\" /><path d=\"M2.5 20a6.5 6.5 0 0 1 13 0M16 4.5a3.5 3.5 0 0 1 0 7M18 14.5a6.5 6.5 0 0 1 3.5 5.5\" /></svg>,\n};\n\nfunction DemoPanel({ title, lines, theme }: { title: string; lines: string[]; theme: \"dark\" | \"light\" }) {\n  const c = theme === \"dark\" ? { t: \"#F5F4F1\", m: \"rgba(245,244,241,0.55)\", b: \"rgba(255,255,255,0.08)\" } : { t: \"#0A0A0A\", m: \"rgba(10,10,10,0.55)\", b: \"rgba(10,10,10,0.08)\" };\n  return (\n    <div className=\"flex flex-col\" style={{ gap: 14 }}>\n      <p className=\"text-[15px] font-semibold\" style={{ color: c.t }}>\n        {title}\n      </p>\n      {lines.map((l) => (\n        <div key={l} className=\"flex items-center justify-between text-[13px]\" style={{ paddingBottom: 12, borderBottom: `1px solid ${c.b}`, color: c.m }}>\n          <span>{l}</span>\n          <span className=\"block rounded-full\" style={{ width: 30, height: 18, background: c.b }} />\n        </div>\n      ))}\n    </div>\n  );\n}\n\nexport function SideTabMenuDemo({ theme = \"dark\" }: { theme?: \"dark\" | \"light\" }) {\n  const tabs: SideTab[] = [\n    { id: \"profile\", label: \"Profile\", description: \"Name, photo and bio\", icon: I.user, group: \"Account\", content: <DemoPanel theme={theme} title=\"Profile\" lines={[\"Display name\", \"Profile photo\", \"Public bio\"]} /> },\n    { id: \"notifications\", label: \"Notifications\", description: \"Email and push\", icon: I.bell, badge: 3, group: \"Account\", content: <DemoPanel theme={theme} title=\"Notifications\" lines={[\"Product updates\", \"Mentions\", \"Weekly digest\"]} /> },\n    { id: \"security\", label: \"Security\", description: \"Password and 2FA\", icon: I.shield, group: \"Account\", content: <DemoPanel theme={theme} title=\"Security\" lines={[\"Two-factor authentication\", \"Active sessions\", \"Login alerts\"]} /> },\n    { id: \"team\", label: \"Team\", description: \"Members and roles\", icon: I.users, group: \"Workspace\", content: <DemoPanel theme={theme} title=\"Team\" lines={[\"Invite members\", \"Default role\", \"Guest access\"]} /> },\n    { id: \"billing\", label: \"Billing\", description: \"Plan and invoices\", icon: I.card, group: \"Workspace\", content: <DemoPanel theme={theme} title=\"Billing\" lines={[\"Current plan\", \"Payment method\", \"Invoices\"]} /> },\n    { id: \"integrations\", label: \"Integrations\", description: \"Connected apps\", icon: I.plug, group: \"Workspace\", disabled: true },\n  ];\n  return (\n    <div className=\"w-[640px] max-w-full\">\n      <SideTabMenu tabs={tabs} theme={theme} label=\"Settings\" />\n    </div>\n  );\n}\n\nexport default SideTabMenu;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}