{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"sidebar-navigation-collection-with-collapsible-icon-rail-nested-groups-and-mobile-drawer","type":"registry:block","title":"Sidebar Navigation Layouts for React and Tailwind","description":"Free React and Tailwind sidebars: collapsible icon rail, two-level rail with panel, nested groups with filter, mobile drawer, dark switcher and HTML only.","dependencies":[],"files":[{"path":"components/we-inc/sidebar-navigation-collection-with-collapsible-icon-rail-nested-groups-and-mobile-drawer.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport type { KeyboardEvent } from \"react\";\n\n/*\n  Sidebar navigation collection.\n  Each sidebar is drawn inside its own relatively positioned app frame with a fixed height, so\n  drawers and overlays stay inside the preview. In your app, swap the frame for the full viewport\n  (h-screen, or fixed inset-0 for the drawer). The copied code is the same component you see.\n*/\n\ntype Fam = \"desktop\" | \"mobile\" | \"plain\";\ntype Lang = \"react\" | \"html\";\ntype Item = { f: Fam; name: string; note: string; Demo: () => JSX.Element; code: Partial<Record<Lang, string>> };\n\nconst FAMILIES: Record<Fam, string> = { desktop: \"Desktop sidebars\", mobile: \"Mobile drawer\", plain: \"HTML only\" };\nconst LANGS: Record<Lang, string> = { react: \"React + Tailwind\", html: \"HTML + Tailwind\" };\n\n/* ---------- shared icons ---------- */\nconst PATHS = {\n  home: \"M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z\",\n  inbox: \"M3 13h5l1.5 3h5L16 13h5M5 5h14l2 8v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-6z\",\n  chart: \"M4 20V10M10 20V4M16 20v-7M22 20H2\",\n  users: \"M16 20v-1a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v1M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM22 20v-1a4 4 0 0 0-3-3.9M16 3.1a4 4 0 0 1 0 7.8\",\n  file: \"M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8zM14 3v5h5\",\n  gear: \"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z\",\n  calendar: \"M8 2v4M16 2v4M3 9h18M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z\",\n  chevron: \"m9 18 6-6-6-6\",\n  panel: \"M3 5h18v14H3zM9 5v14\",\n  menu: \"M4 6h16M4 12h16M4 18h16\",\n  close: \"M6 6l12 12M18 6 6 18\",\n  box: \"M21 8 12 3 3 8v8l9 5 9-5zM3 8l9 5 9-5M12 13v8\",\n} as const;\ntype IconName = keyof typeof PATHS;\n\nfunction Icon({ name, className = \"h-[18px] w-[18px]\" }: { name: IconName; className?: string }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.8} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className={\"shrink-0 \" + className}>\n      <path d={PATHS[name]} />\n    </svg>\n  );\n}\n\nconst ICON_SRC = `const PATHS = {\n  home: \"M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z\",\n  inbox: \"M3 13h5l1.5 3h5L16 13h5M5 5h14l2 8v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-6z\",\n  chart: \"M4 20V10M10 20V4M16 20v-7M22 20H2\",\n  users: \"M16 20v-1a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v1M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM22 20v-1a4 4 0 0 0-3-3.9M16 3.1a4 4 0 0 1 0 7.8\",\n  file: \"M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8zM14 3v5h5\",\n  gear: \"${PATHS.gear}\",\n  calendar: \"M8 2v4M16 2v4M3 9h18M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z\",\n  chevron: \"m9 18 6-6-6-6\",\n  panel: \"M3 5h18v14H3zM9 5v14\",\n  menu: \"M4 6h16M4 12h16M4 18h16\",\n  close: \"M6 6l12 12M18 6 6 18\",\n  box: \"M21 8 12 3 3 8v8l9 5 9-5zM3 8l9 5 9-5M12 13v8\",\n} as const;\ntype IconName = keyof typeof PATHS;\n\nfunction Icon({ name, className = \"h-[18px] w-[18px]\" }: { name: IconName; className?: string }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.8} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" className={\"shrink-0 \" + className}>\n      <path d={PATHS[name]} />\n    </svg>\n  );\n}`;\n\n/* A plain page body used behind every sidebar so the frame reads as a real app. */\nfunction PageBody({ title, dark = false }: { title: string; dark?: boolean }) {\n  return (\n    <div className=\"min-w-0 flex-1 p-5\">\n      <h4 className={\"text-base font-semibold \" + (dark ? \"text-white\" : \"text-slate-900\")}>{title}</h4>\n      <p className={\"mt-1 text-sm \" + (dark ? \"text-slate-400\" : \"text-slate-600\")}>Your page content goes here.</p>\n      <div className=\"mt-4 grid gap-3 sm:grid-cols-3\" aria-hidden=\"true\">\n        {[0, 1, 2].map((k) => (\n          <div key={k} className={\"h-20 rounded-lg \" + (dark ? \"bg-white/[0.04] ring-1 ring-white/10\" : \"bg-white ring-1 ring-slate-200\")} />\n        ))}\n      </div>\n      <div className={\"mt-3 h-28 rounded-lg \" + (dark ? \"bg-white/[0.04] ring-1 ring-white/10\" : \"bg-white ring-1 ring-slate-200\")} aria-hidden=\"true\" />\n    </div>\n  );\n}\n\nconst PAGEBODY_SRC = `function PageBody({ title, dark = false }: { title: string; dark?: boolean }) {\n  return (\n    <div className=\"min-w-0 flex-1 p-5\">\n      <h4 className={\"text-base font-semibold \" + (dark ? \"text-white\" : \"text-slate-900\")}>{title}</h4>\n      <p className={\"mt-1 text-sm \" + (dark ? \"text-slate-400\" : \"text-slate-600\")}>Your page content goes here.</p>\n      <div className=\"mt-4 grid gap-3 sm:grid-cols-3\" aria-hidden=\"true\">\n        {[0, 1, 2].map((k) => (\n          <div key={k} className={\"h-20 rounded-lg \" + (dark ? \"bg-white/[0.04] ring-1 ring-white/10\" : \"bg-white ring-1 ring-slate-200\")} />\n        ))}\n      </div>\n      <div className={\"mt-3 h-28 rounded-lg \" + (dark ? \"bg-white/[0.04] ring-1 ring-white/10\" : \"bg-white ring-1 ring-slate-200\")} aria-hidden=\"true\" />\n    </div>\n  );\n}`;\n\n/* ---------- 1. Collapsible sidebar ---------- */\nconst MAIN_LINKS: { label: string; icon: IconName; count?: number }[] = [\n  { label: \"Overview\", icon: \"home\" },\n  { label: \"Bookings\", icon: \"calendar\", count: 4 },\n  { label: \"Customers\", icon: \"users\" },\n  { label: \"Reports\", icon: \"chart\" },\n  { label: \"Settings\", icon: \"gear\" },\n];\n\nfunction CollapsibleSidebar() {\n  const [collapsed, setCollapsed] = useState(false);\n  const [active, setActive] = useState(\"Bookings\");\n  return (\n    <div className=\"relative flex h-[420px] overflow-hidden rounded-xl border border-slate-200 bg-slate-50\">\n      <aside className={\"flex shrink-0 flex-col border-r border-slate-200 bg-white transition-[width] duration-200 motion-reduce:transition-none \" + (collapsed ? \"w-[64px]\" : \"w-[232px]\")}>\n        <div className=\"flex h-14 items-center gap-2 border-b border-slate-100 px-3\">\n          <span className=\"grid h-8 w-8 shrink-0 place-items-center rounded-md bg-emerald-700 text-sm font-bold text-white\" aria-hidden=\"true\">F</span>\n          {!collapsed && <span className=\"truncate text-sm font-semibold text-slate-900\">Fernhill Physio</span>}\n        </div>\n        <nav aria-label=\"Main\" className=\"flex-1 overflow-y-auto p-2\">\n          <ul className=\"space-y-0.5\">\n            {MAIN_LINKS.map((l) => {\n              const on = l.label === active;\n              return (\n                <li key={l.label}>\n                  <a\n                    href=\"#\"\n                    onClick={(e) => {\n                      e.preventDefault();\n                      setActive(l.label);\n                    }}\n                    aria-current={on ? \"page\" : undefined}\n                    aria-label={collapsed ? l.label : undefined}\n                    title={collapsed ? l.label : undefined}\n                    className={\n                      \"flex h-10 items-center gap-3 rounded-md px-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-700 \" +\n                      (on ? \"bg-emerald-50 font-medium text-emerald-900\" : \"text-slate-700 hover:bg-slate-100\")\n                    }\n                  >\n                    <Icon name={l.icon} />\n                    {!collapsed && <span className=\"flex-1 truncate\">{l.label}</span>}\n                    {!collapsed && l.count ? <span className=\"rounded-full bg-emerald-700 px-1.5 text-[11px] font-semibold text-white\">{l.count}</span> : null}\n                  </a>\n                </li>\n              );\n            })}\n          </ul>\n        </nav>\n        <button\n          type=\"button\"\n          onClick={() => setCollapsed(!collapsed)}\n          aria-expanded={!collapsed}\n          aria-label={collapsed ? \"Expand sidebar\" : \"Collapse sidebar\"}\n          className=\"m-2 flex h-10 items-center gap-3 rounded-md px-3 text-sm text-slate-600 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-700\"\n        >\n          <Icon name=\"panel\" />\n          {!collapsed && <span>Collapse</span>}\n        </button>\n      </aside>\n      <PageBody title={active} />\n    </div>\n  );\n}\n\nconst COLLAPSIBLE_REACT = `import { useState } from \"react\";\n\n${ICON_SRC}\n\n${PAGEBODY_SRC}\n\nconst MAIN_LINKS: { label: string; icon: IconName; count?: number }[] = [\n  { label: \"Overview\", icon: \"home\" },\n  { label: \"Bookings\", icon: \"calendar\", count: 4 },\n  { label: \"Customers\", icon: \"users\" },\n  { label: \"Reports\", icon: \"chart\" },\n  { label: \"Settings\", icon: \"gear\" },\n];\n\n// Collapses from 232px to a 64px icon rail. In the rail each link keeps its name\n// through aria-label (read aloud) and title (shown on hover).\n// In an app, replace h-[420px] on the outer div with h-screen.\nexport function CollapsibleSidebar() {\n  const [collapsed, setCollapsed] = useState(false);\n  const [active, setActive] = useState(\"Bookings\");\n  return (\n    <div className=\"relative flex h-[420px] overflow-hidden rounded-xl border border-slate-200 bg-slate-50\">\n      <aside className={\"flex shrink-0 flex-col border-r border-slate-200 bg-white transition-[width] duration-200 motion-reduce:transition-none \" + (collapsed ? \"w-[64px]\" : \"w-[232px]\")}>\n        <div className=\"flex h-14 items-center gap-2 border-b border-slate-100 px-3\">\n          <span className=\"grid h-8 w-8 shrink-0 place-items-center rounded-md bg-emerald-700 text-sm font-bold text-white\" aria-hidden=\"true\">F</span>\n          {!collapsed && <span className=\"truncate text-sm font-semibold text-slate-900\">Fernhill Physio</span>}\n        </div>\n        <nav aria-label=\"Main\" className=\"flex-1 overflow-y-auto p-2\">\n          <ul className=\"space-y-0.5\">\n            {MAIN_LINKS.map((l) => {\n              const on = l.label === active;\n              return (\n                <li key={l.label}>\n                  <a\n                    href=\"#\"\n                    onClick={(e) => { e.preventDefault(); setActive(l.label); }}\n                    aria-current={on ? \"page\" : undefined}\n                    aria-label={collapsed ? l.label : undefined}\n                    title={collapsed ? l.label : undefined}\n                    className={\n                      \"flex h-10 items-center gap-3 rounded-md px-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-700 \" +\n                      (on ? \"bg-emerald-50 font-medium text-emerald-900\" : \"text-slate-700 hover:bg-slate-100\")\n                    }\n                  >\n                    <Icon name={l.icon} />\n                    {!collapsed && <span className=\"flex-1 truncate\">{l.label}</span>}\n                    {!collapsed && l.count ? <span className=\"rounded-full bg-emerald-700 px-1.5 text-[11px] font-semibold text-white\">{l.count}</span> : null}\n                  </a>\n                </li>\n              );\n            })}\n          </ul>\n        </nav>\n        <button\n          type=\"button\"\n          onClick={() => setCollapsed(!collapsed)}\n          aria-expanded={!collapsed}\n          aria-label={collapsed ? \"Expand sidebar\" : \"Collapse sidebar\"}\n          className=\"m-2 flex h-10 items-center gap-3 rounded-md px-3 text-sm text-slate-600 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-700\"\n        >\n          <Icon name=\"panel\" />\n          {!collapsed && <span>Collapse</span>}\n        </button>\n      </aside>\n      <PageBody title={active} />\n    </div>\n  );\n}`;\n\n/* ---------- 2. Icon rail with a secondary panel ---------- */\nconst SECTIONS: { id: string; label: string; icon: IconName; links: string[] }[] = [\n  { id: \"inbox\", label: \"Inbox\", icon: \"inbox\", links: [\"Unassigned\", \"Mine\", \"Mentions\", \"Archived\"] },\n  { id: \"orders\", label: \"Orders\", icon: \"box\", links: [\"Open\", \"Awaiting payment\", \"Shipped\", \"Returns\"] },\n  { id: \"reports\", label: \"Reports\", icon: \"chart\", links: [\"Sales\", \"Products\", \"Traffic\"] },\n  { id: \"team\", label: \"Team\", icon: \"users\", links: [\"Members\", \"Roles\", \"Invites\"] },\n];\n\nfunction RailSidebar() {\n  const [section, setSection] = useState(\"orders\");\n  const [link, setLink] = useState(\"Awaiting payment\");\n  const current = SECTIONS.find((s) => s.id === section) ?? SECTIONS[0];\n  return (\n    <div className=\"relative flex h-[420px] overflow-hidden rounded-xl border border-slate-200 bg-slate-50\">\n      <nav aria-label=\"Sections\" className=\"flex w-[60px] shrink-0 flex-col items-center gap-1 bg-[#14161b] py-3\">\n        {SECTIONS.map((s) => {\n          const on = s.id === section;\n          return (\n            <button\n              key={s.id}\n              type=\"button\"\n              aria-label={s.label}\n              aria-pressed={on}\n              title={s.label}\n              onClick={() => {\n                setSection(s.id);\n                setLink(s.links[0]);\n              }}\n              className={\"relative grid h-10 w-10 place-items-center rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-300 \" + (on ? \"bg-white/10 text-white\" : \"text-slate-400 hover:bg-white/5 hover:text-slate-100\")}\n            >\n              {on && <span aria-hidden=\"true\" className=\"absolute -left-[10px] h-5 w-[3px] rounded-r bg-sky-300\" />}\n              <Icon name={s.icon} />\n            </button>\n          );\n        })}\n        <span className=\"mt-auto grid h-9 w-9 place-items-center rounded-full bg-sky-200 text-xs font-semibold text-sky-950\" aria-label=\"Signed in as Priya Raman\" role=\"img\">\n          PR\n        </span>\n      </nav>\n      <nav aria-label={current.label} className=\"hidden w-[200px] shrink-0 border-r border-slate-200 bg-white p-3 sm:block\">\n        <p className=\"px-2 pb-2 text-xs font-semibold uppercase tracking-wide text-slate-600\">{current.label}</p>\n        <ul className=\"space-y-0.5\">\n          {current.links.map((l) => (\n            <li key={l}>\n              <a\n                href=\"#\"\n                onClick={(e) => {\n                  e.preventDefault();\n                  setLink(l);\n                }}\n                aria-current={l === link ? \"page\" : undefined}\n                className={\"flex h-10 items-center rounded-md px-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-600 \" + (l === link ? \"bg-slate-100 font-medium text-slate-900\" : \"text-slate-700 hover:bg-slate-50\")}\n              >\n                {l}\n              </a>\n            </li>\n          ))}\n        </ul>\n      </nav>\n      <PageBody title={current.label + \" · \" + link} />\n    </div>\n  );\n}\n\nconst RAIL_REACT = `import { useState } from \"react\";\n\n${ICON_SRC}\n\n${PAGEBODY_SRC}\n\nconst SECTIONS: { id: string; label: string; icon: IconName; links: string[] }[] = [\n  { id: \"inbox\", label: \"Inbox\", icon: \"inbox\", links: [\"Unassigned\", \"Mine\", \"Mentions\", \"Archived\"] },\n  { id: \"orders\", label: \"Orders\", icon: \"box\", links: [\"Open\", \"Awaiting payment\", \"Shipped\", \"Returns\"] },\n  { id: \"reports\", label: \"Reports\", icon: \"chart\", links: [\"Sales\", \"Products\", \"Traffic\"] },\n  { id: \"team\", label: \"Team\", icon: \"users\", links: [\"Members\", \"Roles\", \"Invites\"] },\n];\n\n// Two levels: a dark 60px rail picks the section, a 200px panel lists its pages.\n// Below 640px the panel hides and the rail stands alone.\nexport function RailSidebar() {\n  const [section, setSection] = useState(\"orders\");\n  const [link, setLink] = useState(\"Awaiting payment\");\n  const current = SECTIONS.find((s) => s.id === section) ?? SECTIONS[0];\n  return (\n    <div className=\"relative flex h-[420px] overflow-hidden rounded-xl border border-slate-200 bg-slate-50\">\n      <nav aria-label=\"Sections\" className=\"flex w-[60px] shrink-0 flex-col items-center gap-1 bg-[#14161b] py-3\">\n        {SECTIONS.map((s) => {\n          const on = s.id === section;\n          return (\n            <button\n              key={s.id}\n              type=\"button\"\n              aria-label={s.label}\n              aria-pressed={on}\n              title={s.label}\n              onClick={() => { setSection(s.id); setLink(s.links[0]); }}\n              className={\"relative grid h-10 w-10 place-items-center rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-300 \" + (on ? \"bg-white/10 text-white\" : \"text-slate-400 hover:bg-white/5 hover:text-slate-100\")}\n            >\n              {on && <span aria-hidden=\"true\" className=\"absolute -left-[10px] h-5 w-[3px] rounded-r bg-sky-300\" />}\n              <Icon name={s.icon} />\n            </button>\n          );\n        })}\n        <span className=\"mt-auto grid h-9 w-9 place-items-center rounded-full bg-sky-200 text-xs font-semibold text-sky-950\" aria-label=\"Signed in as Priya Raman\" role=\"img\">\n          PR\n        </span>\n      </nav>\n      <nav aria-label={current.label} className=\"hidden w-[200px] shrink-0 border-r border-slate-200 bg-white p-3 sm:block\">\n        <p className=\"px-2 pb-2 text-xs font-semibold uppercase tracking-wide text-slate-600\">{current.label}</p>\n        <ul className=\"space-y-0.5\">\n          {current.links.map((l) => (\n            <li key={l}>\n              <a\n                href=\"#\"\n                onClick={(e) => { e.preventDefault(); setLink(l); }}\n                aria-current={l === link ? \"page\" : undefined}\n                className={\"flex h-10 items-center rounded-md px-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-600 \" + (l === link ? \"bg-slate-100 font-medium text-slate-900\" : \"text-slate-700 hover:bg-slate-50\")}\n              >\n                {l}\n              </a>\n            </li>\n          ))}\n        </ul>\n      </nav>\n      <PageBody title={current.label + \" · \" + link} />\n    </div>\n  );\n}`;\n\n/* ---------- 3. Nested groups with search ---------- */\nconst GROUPS = [\n  { title: \"Getting started\", links: [\"Install\", \"Your first page\", \"Project structure\"] },\n  { title: \"Content\", links: [\"Pages\", \"Blog posts\", \"Images\", \"Forms\"] },\n  { title: \"Publishing\", links: [\"Custom domains\", \"Redirects\", \"Search settings\"] },\n  { title: \"Account\", links: [\"Billing\", \"Team members\"] },\n];\n\nfunction NestedSidebar() {\n  const [open, setOpen] = useState<Record<string, boolean>>({ \"Getting started\": false, Content: true, Publishing: true, Account: false });\n  const [active, setActive] = useState(\"Images\");\n  const [q, setQ] = useState(\"\");\n  const query = q.trim().toLowerCase();\n  return (\n    <div className=\"relative flex h-[420px] overflow-hidden rounded-xl border border-stone-200 bg-[#fbfaf8]\">\n      <aside className=\"flex w-[248px] shrink-0 flex-col border-r border-stone-200 bg-[#f4f2ee]\">\n        <div className=\"p-3\">\n          <label htmlFor=\"sn-docs-filter\" className=\"sr-only\">Filter pages</label>\n          <input id=\"sn-docs-filter\" type=\"search\" value={q} onChange={(e) => setQ(e.target.value)} placeholder=\"Filter pages\" className=\"h-10 w-full rounded-md border border-stone-300 bg-white px-3 text-sm text-stone-900 placeholder:text-stone-500 focus:outline-none focus-visible:ring-2 focus-visible:ring-amber-700\" />\n        </div>\n        <nav aria-label=\"Documentation\" className=\"flex-1 overflow-y-auto px-2 pb-3\">\n          <ul className=\"space-y-1\">\n            {GROUPS.map((g) => {\n              const links = g.links.filter((l) => !query || l.toLowerCase().includes(query));\n              if (query && links.length === 0) return null;\n              const isOpen = query ? true : !!open[g.title];\n              const id = \"sn-group-\" + g.title.replace(/\\s+/g, \"-\").toLowerCase();\n              return (\n                <li key={g.title}>\n                  <button\n                    type=\"button\"\n                    aria-expanded={isOpen}\n                    aria-controls={id}\n                    onClick={() => setOpen({ ...open, [g.title]: !open[g.title] })}\n                    className=\"flex h-10 w-full items-center gap-2 rounded-md px-2 text-left text-sm font-semibold text-stone-900 hover:bg-stone-200/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-700\"\n                  >\n                    <Icon name=\"chevron\" className={\"h-4 w-4 text-stone-500 transition-transform motion-reduce:transition-none \" + (isOpen ? \"rotate-90\" : \"\")} />\n                    {g.title}\n                  </button>\n                  {isOpen && (\n                    <ul id={id} className=\"ml-[15px] border-l border-stone-300 pl-2\">\n                      {links.map((l) => (\n                        <li key={l}>\n                          <a\n                            href=\"#\"\n                            onClick={(e) => {\n                              e.preventDefault();\n                              setActive(l);\n                            }}\n                            aria-current={l === active ? \"page\" : undefined}\n                            className={\"-ml-[9px] flex h-9 items-center border-l-2 pl-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-700 \" + (l === active ? \"border-amber-700 font-medium text-amber-900\" : \"border-transparent text-stone-700 hover:text-stone-950\")}\n                          >\n                            {l}\n                          </a>\n                        </li>\n                      ))}\n                    </ul>\n                  )}\n                </li>\n              );\n            })}\n          </ul>\n          {query && GROUPS.every((g) => !g.links.some((l) => l.toLowerCase().includes(query))) && <p className=\"px-2 py-3 text-sm text-stone-600\">No page matches \"{q}\".</p>}\n        </nav>\n      </aside>\n      <PageBody title={active} />\n    </div>\n  );\n}\n\nconst NESTED_REACT = `import { useState } from \"react\";\n\n${ICON_SRC}\n\n${PAGEBODY_SRC}\n\nconst GROUPS = [\n  { title: \"Getting started\", links: [\"Install\", \"Your first page\", \"Project structure\"] },\n  { title: \"Content\", links: [\"Pages\", \"Blog posts\", \"Images\", \"Forms\"] },\n  { title: \"Publishing\", links: [\"Custom domains\", \"Redirects\", \"Search settings\"] },\n  { title: \"Account\", links: [\"Billing\", \"Team members\"] },\n];\n\n// Each group is a disclosure: a button with aria-expanded that shows or hides its list.\n// Typing in the filter opens every group with a match and hides the rest.\nexport function NestedSidebar() {\n  const [open, setOpen] = useState<Record<string, boolean>>({ \"Getting started\": false, Content: true, Publishing: true, Account: false });\n  const [active, setActive] = useState(\"Images\");\n  const [q, setQ] = useState(\"\");\n  const query = q.trim().toLowerCase();\n  return (\n    <div className=\"relative flex h-[420px] overflow-hidden rounded-xl border border-stone-200 bg-[#fbfaf8]\">\n      <aside className=\"flex w-[248px] shrink-0 flex-col border-r border-stone-200 bg-[#f4f2ee]\">\n        <div className=\"p-3\">\n          <label htmlFor=\"sn-docs-filter\" className=\"sr-only\">Filter pages</label>\n          <input id=\"sn-docs-filter\" type=\"search\" value={q} onChange={(e) => setQ(e.target.value)} placeholder=\"Filter pages\" className=\"h-10 w-full rounded-md border border-stone-300 bg-white px-3 text-sm text-stone-900 placeholder:text-stone-500 focus:outline-none focus-visible:ring-2 focus-visible:ring-amber-700\" />\n        </div>\n        <nav aria-label=\"Documentation\" className=\"flex-1 overflow-y-auto px-2 pb-3\">\n          <ul className=\"space-y-1\">\n            {GROUPS.map((g) => {\n              const links = g.links.filter((l) => !query || l.toLowerCase().includes(query));\n              if (query && links.length === 0) return null;\n              const isOpen = query ? true : !!open[g.title];\n              const id = \"sn-group-\" + g.title.replace(/\\\\s+/g, \"-\").toLowerCase();\n              return (\n                <li key={g.title}>\n                  <button\n                    type=\"button\"\n                    aria-expanded={isOpen}\n                    aria-controls={id}\n                    onClick={() => setOpen({ ...open, [g.title]: !open[g.title] })}\n                    className=\"flex h-10 w-full items-center gap-2 rounded-md px-2 text-left text-sm font-semibold text-stone-900 hover:bg-stone-200/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-700\"\n                  >\n                    <Icon name=\"chevron\" className={\"h-4 w-4 text-stone-500 transition-transform motion-reduce:transition-none \" + (isOpen ? \"rotate-90\" : \"\")} />\n                    {g.title}\n                  </button>\n                  {isOpen && (\n                    <ul id={id} className=\"ml-[15px] border-l border-stone-300 pl-2\">\n                      {links.map((l) => (\n                        <li key={l}>\n                          <a\n                            href=\"#\"\n                            onClick={(e) => { e.preventDefault(); setActive(l); }}\n                            aria-current={l === active ? \"page\" : undefined}\n                            className={\"-ml-[9px] flex h-9 items-center border-l-2 pl-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-700 \" + (l === active ? \"border-amber-700 font-medium text-amber-900\" : \"border-transparent text-stone-700 hover:text-stone-950\")}\n                          >\n                            {l}\n                          </a>\n                        </li>\n                      ))}\n                    </ul>\n                  )}\n                </li>\n              );\n            })}\n          </ul>\n          {query && GROUPS.every((g) => !g.links.some((l) => l.toLowerCase().includes(query))) && <p className=\"px-2 py-3 text-sm text-stone-600\">No page matches \"{q}\".</p>}\n        </nav>\n      </aside>\n      <PageBody title={active} />\n    </div>\n  );\n}`;\n\n/* ---------- 4. Mobile drawer ---------- */\nconst DRAWER_LINKS: { label: string; icon: IconName }[] = [\n  { label: \"Today\", icon: \"home\" },\n  { label: \"Schedule\", icon: \"calendar\" },\n  { label: \"Clients\", icon: \"users\" },\n  { label: \"Invoices\", icon: \"file\" },\n  { label: \"Settings\", icon: \"gear\" },\n];\n\nfunction MobileDrawer() {\n  const [open, setOpen] = useState(true);\n  const [active, setActive] = useState(\"Schedule\");\n  const opener = useRef<HTMLButtonElement | null>(null);\n  const panel = useRef<HTMLDivElement | null>(null);\n  const first = useRef(true);\n\n  useEffect(() => {\n    if (first.current) {\n      first.current = false;\n      return;\n    }\n    if (open) panel.current?.querySelector<HTMLElement>(\"a,button\")?.focus();\n    else opener.current?.focus();\n  }, [open]);\n\n  const onKeyDown = (e: KeyboardEvent) => {\n    if (e.key === \"Escape\") setOpen(false);\n    if (e.key !== \"Tab\" || !panel.current) return;\n    const items = panel.current.querySelectorAll<HTMLElement>(\"a,button\");\n    const a = items[0];\n    const z = items[items.length - 1];\n    if (e.shiftKey && document.activeElement === a) {\n      e.preventDefault();\n      z.focus();\n    } else if (!e.shiftKey && document.activeElement === z) {\n      e.preventDefault();\n      a.focus();\n    }\n  };\n\n  return (\n    <div className=\"relative mx-auto h-[460px] w-full max-w-[380px] overflow-hidden rounded-[28px] border-[6px] border-[#1d1f24] bg-white\">\n      <header className=\"flex h-14 items-center gap-2 border-b border-slate-200 px-2\">\n        <button ref={opener} type=\"button\" onClick={() => setOpen(true)} aria-expanded={open} aria-controls=\"sn-drawer\" aria-label=\"Open menu\" className=\"grid h-11 w-11 place-items-center rounded-lg text-slate-800 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-700\">\n          <Icon name=\"menu\" className=\"h-5 w-5\" />\n        </button>\n        <span className=\"text-sm font-semibold text-slate-900\">{active}</span>\n      </header>\n      <PageBody title={active} />\n\n      <div aria-hidden=\"true\" onClick={() => setOpen(false)} className={\"absolute inset-0 bg-slate-900/40 transition-opacity duration-200 motion-reduce:transition-none \" + (open ? \"opacity-100\" : \"pointer-events-none opacity-0\")} />\n      <div\n        ref={panel}\n        id=\"sn-drawer\"\n        role=\"dialog\"\n        aria-modal=\"true\"\n        aria-label=\"Menu\"\n        onKeyDown={onKeyDown}\n        className={\"absolute inset-y-0 left-0 flex w-[78%] max-w-[300px] flex-col bg-white shadow-[8px_0_32px_-12px_rgba(15,23,42,0.35)] transition-transform duration-300 ease-out motion-reduce:transition-none \" + (open ? \"translate-x-0\" : \"invisible -translate-x-full\")}\n      >\n        <div className=\"flex h-14 items-center justify-between border-b border-slate-100 pl-4 pr-2\">\n          <span className=\"text-sm font-semibold text-slate-900\">Copperleaf Studio</span>\n          <button type=\"button\" onClick={() => setOpen(false)} aria-label=\"Close menu\" className=\"grid h-11 w-11 place-items-center rounded-lg text-slate-700 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-700\">\n            <Icon name=\"close\" className=\"h-5 w-5\" />\n          </button>\n        </div>\n        <nav aria-label=\"Main\" className=\"flex-1 overflow-y-auto p-2\">\n          <ul className=\"space-y-0.5\">\n            {DRAWER_LINKS.map((l) => (\n              <li key={l.label}>\n                <a\n                  href=\"#\"\n                  onClick={(e) => {\n                    e.preventDefault();\n                    setActive(l.label);\n                    setOpen(false);\n                  }}\n                  aria-current={l.label === active ? \"page\" : undefined}\n                  className={\"flex h-12 items-center gap-3 rounded-lg px-3 text-[15px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-700 \" + (l.label === active ? \"bg-violet-50 font-medium text-violet-900\" : \"text-slate-700 hover:bg-slate-50\")}\n                >\n                  <Icon name={l.icon} />\n                  {l.label}\n                </a>\n              </li>\n            ))}\n          </ul>\n        </nav>\n        <p className=\"border-t border-slate-100 p-4 text-xs text-slate-600\">Signed in as Maya Lindqvist</p>\n      </div>\n    </div>\n  );\n}\n\nconst DRAWER_REACT = `import { useEffect, useRef, useState } from \"react\";\nimport type { KeyboardEvent } from \"react\";\n\n${ICON_SRC}\n\n${PAGEBODY_SRC}\n\nconst DRAWER_LINKS: { label: string; icon: IconName }[] = [\n  { label: \"Today\", icon: \"home\" },\n  { label: \"Schedule\", icon: \"calendar\" },\n  { label: \"Clients\", icon: \"users\" },\n  { label: \"Invoices\", icon: \"file\" },\n  { label: \"Settings\", icon: \"gear\" },\n];\n\n// A modal drawer: focus moves into it on open, Tab stays inside, Escape or the dim\n// overlay closes it, and focus returns to the menu button. Here it is drawn inside a\n// phone frame; in a real page change the outer div to \"fixed inset-0 z-50\" for the\n// overlay and drawer, and use h-screen for the layout.\nexport function MobileDrawer() {\n  const [open, setOpen] = useState(true);\n  const [active, setActive] = useState(\"Schedule\");\n  const opener = useRef<HTMLButtonElement | null>(null);\n  const panel = useRef<HTMLDivElement | null>(null);\n  const first = useRef(true);\n\n  useEffect(() => {\n    if (first.current) {\n      first.current = false;\n      return;\n    }\n    if (open) panel.current?.querySelector<HTMLElement>(\"a,button\")?.focus();\n    else opener.current?.focus();\n  }, [open]);\n\n  const onKeyDown = (e: KeyboardEvent) => {\n    if (e.key === \"Escape\") setOpen(false);\n    if (e.key !== \"Tab\" || !panel.current) return;\n    const items = panel.current.querySelectorAll<HTMLElement>(\"a,button\");\n    const a = items[0];\n    const z = items[items.length - 1];\n    if (e.shiftKey && document.activeElement === a) {\n      e.preventDefault();\n      z.focus();\n    } else if (!e.shiftKey && document.activeElement === z) {\n      e.preventDefault();\n      a.focus();\n    }\n  };\n\n  return (\n    <div className=\"relative mx-auto h-[460px] w-full max-w-[380px] overflow-hidden rounded-[28px] border-[6px] border-[#1d1f24] bg-white\">\n      <header className=\"flex h-14 items-center gap-2 border-b border-slate-200 px-2\">\n        <button ref={opener} type=\"button\" onClick={() => setOpen(true)} aria-expanded={open} aria-controls=\"sn-drawer\" aria-label=\"Open menu\" className=\"grid h-11 w-11 place-items-center rounded-lg text-slate-800 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-700\">\n          <Icon name=\"menu\" className=\"h-5 w-5\" />\n        </button>\n        <span className=\"text-sm font-semibold text-slate-900\">{active}</span>\n      </header>\n      <PageBody title={active} />\n\n      <div aria-hidden=\"true\" onClick={() => setOpen(false)} className={\"absolute inset-0 bg-slate-900/40 transition-opacity duration-200 motion-reduce:transition-none \" + (open ? \"opacity-100\" : \"pointer-events-none opacity-0\")} />\n      <div\n        ref={panel}\n        id=\"sn-drawer\"\n        role=\"dialog\"\n        aria-modal=\"true\"\n        aria-label=\"Menu\"\n        onKeyDown={onKeyDown}\n        className={\"absolute inset-y-0 left-0 flex w-[78%] max-w-[300px] flex-col bg-white shadow-[8px_0_32px_-12px_rgba(15,23,42,0.35)] transition-transform duration-300 ease-out motion-reduce:transition-none \" + (open ? \"translate-x-0\" : \"invisible -translate-x-full\")}\n      >\n        <div className=\"flex h-14 items-center justify-between border-b border-slate-100 pl-4 pr-2\">\n          <span className=\"text-sm font-semibold text-slate-900\">Copperleaf Studio</span>\n          <button type=\"button\" onClick={() => setOpen(false)} aria-label=\"Close menu\" className=\"grid h-11 w-11 place-items-center rounded-lg text-slate-700 hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-700\">\n            <Icon name=\"close\" className=\"h-5 w-5\" />\n          </button>\n        </div>\n        <nav aria-label=\"Main\" className=\"flex-1 overflow-y-auto p-2\">\n          <ul className=\"space-y-0.5\">\n            {DRAWER_LINKS.map((l) => (\n              <li key={l.label}>\n                <a\n                  href=\"#\"\n                  onClick={(e) => { e.preventDefault(); setActive(l.label); setOpen(false); }}\n                  aria-current={l.label === active ? \"page\" : undefined}\n                  className={\"flex h-12 items-center gap-3 rounded-lg px-3 text-[15px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-700 \" + (l.label === active ? \"bg-violet-50 font-medium text-violet-900\" : \"text-slate-700 hover:bg-slate-50\")}\n                >\n                  <Icon name={l.icon} />\n                  {l.label}\n                </a>\n              </li>\n            ))}\n          </ul>\n        </nav>\n        <p className=\"border-t border-slate-100 p-4 text-xs text-slate-600\">Signed in as Maya Lindqvist</p>\n      </div>\n    </div>\n  );\n}`;\n\n/* ---------- 5. Dark workspace sidebar ---------- */\nconst WORKSPACES = [\"Harbourline Studio\", \"Mesa Ceramics\", \"Personal\"];\nconst DARK_GROUPS: { title: string; links: { label: string; icon: IconName; badge?: string }[] }[] = [\n  { title: \"Workspace\", links: [{ label: \"Dashboard\", icon: \"home\" }, { label: \"Projects\", icon: \"box\", badge: \"12\" }, { label: \"Messages\", icon: \"inbox\", badge: \"3\" }] },\n  { title: \"Insights\", links: [{ label: \"Analytics\", icon: \"chart\" }, { label: \"Documents\", icon: \"file\" }] },\n];\n\nfunction DarkSidebar() {\n  const [ws, setWs] = useState(0);\n  const [menu, setMenu] = useState(false);\n  const [active, setActive] = useState(\"Projects\");\n  return (\n    <div className=\"relative flex h-[420px] overflow-hidden rounded-xl border border-slate-800 bg-[#0d0f12]\">\n      <aside className=\"flex w-[240px] shrink-0 flex-col border-r border-white/10 bg-[#111317]\">\n        <div className=\"relative p-3\">\n          <button type=\"button\" onClick={() => setMenu(!menu)} aria-expanded={menu} aria-haspopup=\"true\" aria-controls=\"sn-ws-list\" className=\"flex h-11 w-full items-center gap-2.5 rounded-lg px-2 text-left hover:bg-white/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-300\">\n            <span className=\"grid h-7 w-7 place-items-center rounded-md bg-orange-300 text-xs font-bold text-[#111317]\" aria-hidden=\"true\">{WORKSPACES[ws][0]}</span>\n            <span className=\"min-w-0 flex-1\">\n              <span className=\"block truncate text-sm font-semibold text-white\">{WORKSPACES[ws]}</span>\n              <span className=\"block text-[11px] text-slate-400\">Switch workspace</span>\n            </span>\n            <Icon name=\"chevron\" className={\"h-4 w-4 text-slate-400 transition-transform motion-reduce:transition-none \" + (menu ? \"-rotate-90\" : \"rotate-90\")} />\n          </button>\n          {menu && (\n            <ul id=\"sn-ws-list\" className=\"absolute left-3 right-3 top-[60px] z-10 rounded-lg border border-white/10 bg-[#1a1d22] p-1 shadow-xl\">\n              {WORKSPACES.map((w, i) => (\n                <li key={w}>\n                  <button\n                    type=\"button\"\n                    aria-pressed={i === ws}\n                    onClick={() => {\n                      setWs(i);\n                      setMenu(false);\n                    }}\n                    className={\"flex h-10 w-full items-center rounded-md px-2.5 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-300 \" + (i === ws ? \"bg-white/10 text-white\" : \"text-slate-300 hover:bg-white/5\")}\n                  >\n                    {w}\n                  </button>\n                </li>\n              ))}\n            </ul>\n          )}\n        </div>\n        <nav aria-label=\"Main\" className=\"flex-1 overflow-y-auto px-3\">\n          {DARK_GROUPS.map((g) => (\n            <div key={g.title} className=\"mb-4\">\n              <h5 className=\"px-2 pb-1 text-[11px] font-medium uppercase tracking-[0.12em] text-slate-400\">{g.title}</h5>\n              <ul className=\"space-y-0.5\">\n                {g.links.map((l) => {\n                  const on = l.label === active;\n                  return (\n                    <li key={l.label}>\n                      <a\n                        href=\"#\"\n                        onClick={(e) => {\n                          e.preventDefault();\n                          setActive(l.label);\n                        }}\n                        aria-current={on ? \"page\" : undefined}\n                        className={\"flex h-10 items-center gap-3 rounded-lg px-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-300 \" + (on ? \"bg-white/[0.08] text-white\" : \"text-slate-300 hover:bg-white/5 hover:text-white\")}\n                      >\n                        <Icon name={l.icon} />\n                        <span className=\"flex-1\">{l.label}</span>\n                        {l.badge && <span className=\"font-mono text-[11px] text-slate-400\">{l.badge}</span>}\n                      </a>\n                    </li>\n                  );\n                })}\n              </ul>\n            </div>\n          ))}\n        </nav>\n        <div className=\"flex items-center gap-2.5 border-t border-white/10 p-3\">\n          <span className=\"grid h-8 w-8 place-items-center rounded-full bg-slate-700 text-xs font-semibold text-white\" aria-hidden=\"true\">DA</span>\n          <span className=\"min-w-0 flex-1\">\n            <span className=\"block truncate text-sm text-white\">Dara Achebe</span>\n            <span className=\"block truncate text-[11px] text-slate-400\">Owner</span>\n          </span>\n          <a href=\"#\" aria-label=\"Account settings\" className=\"grid h-10 w-10 place-items-center rounded-lg text-slate-400 hover:bg-white/5 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-300\">\n            <Icon name=\"gear\" />\n          </a>\n        </div>\n      </aside>\n      <PageBody title={active} dark />\n    </div>\n  );\n}\n\nconst DARK_REACT = `import { useState } from \"react\";\n\n${ICON_SRC}\n\n${PAGEBODY_SRC}\n\nconst WORKSPACES = [\"Harbourline Studio\", \"Mesa Ceramics\", \"Personal\"];\nconst DARK_GROUPS: { title: string; links: { label: string; icon: IconName; badge?: string }[] }[] = [\n  { title: \"Workspace\", links: [{ label: \"Dashboard\", icon: \"home\" }, { label: \"Projects\", icon: \"box\", badge: \"12\" }, { label: \"Messages\", icon: \"inbox\", badge: \"3\" }] },\n  { title: \"Insights\", links: [{ label: \"Analytics\", icon: \"chart\" }, { label: \"Documents\", icon: \"file\" }] },\n];\n\n// Workspace switcher on top, grouped links with counts, the signed-in person at the foot.\nexport function DarkSidebar() {\n  const [ws, setWs] = useState(0);\n  const [menu, setMenu] = useState(false);\n  const [active, setActive] = useState(\"Projects\");\n  return (\n    <div className=\"relative flex h-[420px] overflow-hidden rounded-xl border border-slate-800 bg-[#0d0f12]\">\n      <aside className=\"flex w-[240px] shrink-0 flex-col border-r border-white/10 bg-[#111317]\">\n        <div className=\"relative p-3\">\n          <button type=\"button\" onClick={() => setMenu(!menu)} aria-expanded={menu} aria-haspopup=\"true\" aria-controls=\"sn-ws-list\" className=\"flex h-11 w-full items-center gap-2.5 rounded-lg px-2 text-left hover:bg-white/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-300\">\n            <span className=\"grid h-7 w-7 place-items-center rounded-md bg-orange-300 text-xs font-bold text-[#111317]\" aria-hidden=\"true\">{WORKSPACES[ws][0]}</span>\n            <span className=\"min-w-0 flex-1\">\n              <span className=\"block truncate text-sm font-semibold text-white\">{WORKSPACES[ws]}</span>\n              <span className=\"block text-[11px] text-slate-400\">Switch workspace</span>\n            </span>\n            <Icon name=\"chevron\" className={\"h-4 w-4 text-slate-400 transition-transform motion-reduce:transition-none \" + (menu ? \"-rotate-90\" : \"rotate-90\")} />\n          </button>\n          {menu && (\n            <ul id=\"sn-ws-list\" className=\"absolute left-3 right-3 top-[60px] z-10 rounded-lg border border-white/10 bg-[#1a1d22] p-1 shadow-xl\">\n              {WORKSPACES.map((w, i) => (\n                <li key={w}>\n                  <button\n                    type=\"button\"\n                    aria-pressed={i === ws}\n                    onClick={() => { setWs(i); setMenu(false); }}\n                    className={\"flex h-10 w-full items-center rounded-md px-2.5 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-300 \" + (i === ws ? \"bg-white/10 text-white\" : \"text-slate-300 hover:bg-white/5\")}\n                  >\n                    {w}\n                  </button>\n                </li>\n              ))}\n            </ul>\n          )}\n        </div>\n        <nav aria-label=\"Main\" className=\"flex-1 overflow-y-auto px-3\">\n          {DARK_GROUPS.map((g) => (\n            <div key={g.title} className=\"mb-4\">\n              <h5 className=\"px-2 pb-1 text-[11px] font-medium uppercase tracking-[0.12em] text-slate-400\">{g.title}</h5>\n              <ul className=\"space-y-0.5\">\n                {g.links.map((l) => {\n                  const on = l.label === active;\n                  return (\n                    <li key={l.label}>\n                      <a\n                        href=\"#\"\n                        onClick={(e) => { e.preventDefault(); setActive(l.label); }}\n                        aria-current={on ? \"page\" : undefined}\n                        className={\"flex h-10 items-center gap-3 rounded-lg px-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-300 \" + (on ? \"bg-white/[0.08] text-white\" : \"text-slate-300 hover:bg-white/5 hover:text-white\")}\n                      >\n                        <Icon name={l.icon} />\n                        <span className=\"flex-1\">{l.label}</span>\n                        {l.badge && <span className=\"font-mono text-[11px] text-slate-400\">{l.badge}</span>}\n                      </a>\n                    </li>\n                  );\n                })}\n              </ul>\n            </div>\n          ))}\n        </nav>\n        <div className=\"flex items-center gap-2.5 border-t border-white/10 p-3\">\n          <span className=\"grid h-8 w-8 place-items-center rounded-full bg-slate-700 text-xs font-semibold text-white\" aria-hidden=\"true\">DA</span>\n          <span className=\"min-w-0 flex-1\">\n            <span className=\"block truncate text-sm text-white\">Dara Achebe</span>\n            <span className=\"block truncate text-[11px] text-slate-400\">Owner</span>\n          </span>\n          <a href=\"#\" aria-label=\"Account settings\" className=\"grid h-10 w-10 place-items-center rounded-lg text-slate-400 hover:bg-white/5 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-300\">\n            <Icon name=\"gear\" />\n          </a>\n        </div>\n      </aside>\n      <PageBody title={active} dark />\n    </div>\n  );\n}`;\n\n/* ---------- 6. HTML only, using details and summary ---------- */\nconst HTML_GROUPS = [\n  { title: \"Menu\", open: true, links: [\"Breakfast\", \"Lunch\", \"Cakes to order\"] },\n  { title: \"Visit\", open: true, links: [\"Opening hours\", \"Find us\"] },\n  { title: \"About\", open: false, links: [\"Our bakers\", \"Suppliers\"] },\n];\n\nfunction HtmlSidebar() {\n  return (\n    <div className=\"relative flex h-[420px] overflow-hidden rounded-xl border border-sky-100 bg-white\">\n      <nav aria-label=\"Site\" className=\"w-[220px] shrink-0 overflow-y-auto border-r border-sky-100 bg-sky-50/60 p-3\">\n        <a href=\"#\" className=\"mb-3 flex h-10 items-center px-2 text-sm font-semibold text-sky-950 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-700\">\n          Tidewater Bakery\n        </a>\n        {HTML_GROUPS.map((g) => (\n          <details key={g.title} open={g.open} className=\"group mb-1\">\n            <summary className=\"flex h-10 cursor-pointer list-none items-center justify-between rounded-md px-2 text-sm font-medium text-slate-900 hover:bg-sky-100/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-700 [&::-webkit-details-marker]:hidden\">\n              {g.title}\n              <Icon name=\"chevron\" className=\"h-4 w-4 text-slate-500 transition-transform group-open:rotate-90 motion-reduce:transition-none\" />\n            </summary>\n            <ul className=\"pb-1 pl-2\">\n              {g.links.map((l) => (\n                <li key={l}>\n                  <a href=\"#\" aria-current={l === \"Opening hours\" ? \"page\" : undefined} className={\"flex h-9 items-center rounded-md px-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-700 \" + (l === \"Opening hours\" ? \"bg-white font-medium text-sky-900 shadow-sm ring-1 ring-sky-100\" : \"text-slate-700 hover:text-slate-950\")}>\n                    {l}\n                  </a>\n                </li>\n              ))}\n            </ul>\n          </details>\n        ))}\n      </nav>\n      <PageBody title=\"Opening hours\" />\n    </div>\n  );\n}\n\nconst SUMMARY_CLS = \"flex h-10 cursor-pointer list-none items-center justify-between rounded-md px-2 text-sm font-medium text-slate-900 hover:bg-sky-100/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-700 [&::-webkit-details-marker]:hidden\";\nconst LINK_ON = \"flex h-9 items-center rounded-md px-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-700 bg-white font-medium text-sky-900 shadow-sm ring-1 ring-sky-100\";\nconst LINK_OFF = \"flex h-9 items-center rounded-md px-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-700 text-slate-700 hover:text-slate-950\";\nconst linkHtml = (l: string) => (l === \"Opening hours\" ? `      <li><a href=\"#\" aria-current=\"page\" class=\"${LINK_ON}\">${l}</a></li>` : `      <li><a href=\"#\" class=\"${LINK_OFF}\">${l}</a></li>`);\nconst groupHtml = (g: (typeof HTML_GROUPS)[number]) => `  <details${g.open ? \" open\" : \"\"} class=\"group mb-1\">\n    <summary class=\"${SUMMARY_CLS}\">\n      ${g.title}\n      <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" class=\"h-4 w-4 shrink-0 text-slate-500 transition-transform group-open:rotate-90 motion-reduce:transition-none\"><path d=\"m9 18 6-6-6-6\"/></svg>\n    </summary>\n    <ul class=\"pb-1 pl-2\">\n${g.links.map(linkHtml).join(\"\\n\")}\n    </ul>\n  </details>`;\nconst HTML_SRC = `<!-- No JavaScript: each group is a details element, so it opens and closes natively\n     and announces its state. Mark the current page with aria-current=\"page\". -->\n<nav aria-label=\"Site\" class=\"w-[220px] shrink-0 overflow-y-auto border-r border-sky-100 bg-sky-50/60 p-3\">\n  <a href=\"/\" class=\"mb-3 flex h-10 items-center px-2 text-sm font-semibold text-sky-950 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-700\">Tidewater Bakery</a>\n${HTML_GROUPS.map(groupHtml).join(\"\\n\")}\n</nav>`;\n\n/* ---------- catalogue ---------- */\nconst ITEMS: Item[] = [\n  { f: \"desktop\", name: \"Collapsible to an icon rail\", note: \"232px with labels, 64px with icons. Press Collapse.\", Demo: CollapsibleSidebar, code: { react: COLLAPSIBLE_REACT } },\n  { f: \"mobile\", name: \"Mobile drawer\", note: \"Opens over the page with a dim overlay; Escape, the overlay or a link closes it and focus returns to the menu button.\", Demo: MobileDrawer, code: { react: DRAWER_REACT } },\n  { f: \"desktop\", name: \"Icon rail with a section panel\", note: \"Rail chooses the section, the panel lists its pages.\", Demo: RailSidebar, code: { react: RAIL_REACT } },\n  { f: \"desktop\", name: \"Nested groups with a filter\", note: \"Disclosure groups for docs and help centres. Type to filter.\", Demo: NestedSidebar, code: { react: NESTED_REACT } },\n  { f: \"desktop\", name: \"Dark sidebar with workspace switcher\", note: \"Grouped links, counts and the signed-in person at the foot.\", Demo: DarkSidebar, code: { react: DARK_REACT } },\n  { f: \"plain\", name: \"HTML sidebar with details groups\", note: \"Opens and closes with no JavaScript at all.\", Demo: HtmlSidebar, code: { html: HTML_SRC } },\n];\n\nconst RING = \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-200 focus-visible:ring-offset-2 focus-visible:ring-offset-[#17191d]\";\n\nfunction Card({ item, n }: { item: Item; n: number }) {\n  const langs = Object.keys(item.code) as Lang[];\n  const [lang] = useState<Lang>(langs[0]);\n  const [open, setOpen] = useState(false);\n  const [copied, setCopied] = useState(false);\n  const [msg, setMsg] = useState(\"\");\n  const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n  useEffect(() => () => {\n    if (timer.current) clearTimeout(timer.current);\n  }, []);\n  const code = item.code[lang] ?? \"\";\n  const id = `sn-code-${n}`;\n  async function copy() {\n    let ok = false;\n    try {\n      await navigator.clipboard.writeText(code);\n      ok = true;\n    } catch {\n      ok = false;\n    }\n    if (!ok) setOpen(true);\n    setCopied(ok);\n    setMsg(ok ? `${item.name}, ${LANGS[lang]}, copied` : \"Copy was blocked. The code is open below so you can select it.\");\n    if (timer.current) clearTimeout(timer.current);\n    timer.current = setTimeout(() => setCopied(false), 1600);\n  }\n  const Demo = item.Demo;\n  const tool = `inline-flex h-10 items-center justify-center gap-1.5 rounded-lg px-3 text-[12.5px] font-semibold transition-colors ${RING}`;\n  return (\n    <li className=\"min-w-0 overflow-hidden rounded-2xl border border-white/10 bg-[#1d2025]\">\n      <div className=\"flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 sm:px-5\">\n        <span className=\"font-mono text-[11px] text-slate-400\">{String(n).padStart(2, \"0\")}</span>\n        <div className=\"min-w-0 flex-1\">\n          <h3 className=\"text-[15px] font-semibold tracking-tight text-white\">{item.name}</h3>\n          <p className=\"mt-0.5 text-[13px] leading-snug text-slate-400\">{item.note}</p>\n        </div>\n        <span className=\"text-[12px] font-medium text-slate-400\">{LANGS[lang]}</span>\n        <button type=\"button\" aria-expanded={open} aria-controls={id} onClick={() => setOpen(!open)} className={`${tool} text-slate-200 hover:bg-white/10`}>\n          {open ? \"Hide code\" : \"Show code\"}\n        </button>\n        <button type=\"button\" onClick={copy} aria-label={`Copy ${LANGS[lang]} code for ${item.name}`} className={`${tool} ${copied ? \"bg-emerald-600 text-white\" : \"bg-white text-slate-900 hover:bg-slate-200\"}`}>\n          {copied ? \"Copied\" : \"Copy\"}\n        </button>\n      </div>\n      <p className=\"sr-only\" aria-live=\"polite\">\n        {msg}\n      </p>\n      <div className=\"overflow-x-auto bg-[#26292f] p-3 sm:p-5\">\n        <div className=\"min-w-[340px]\">\n          <Demo />\n        </div>\n      </div>\n      {open && (\n        <pre id={id} tabIndex={0} aria-label={`${item.name} code`} className={`max-h-96 overflow-auto border-t border-white/10 bg-[#0e1013] p-4 font-mono text-[11.5px] leading-[1.65] text-slate-200 ${RING}`}>\n          <code>{code}</code>\n        </pre>\n      )}\n    </li>\n  );\n}\n\nconst FAM_KEYS = Object.keys(FAMILIES) as Fam[];\n\nexport default function SidebarNavigationCollection() {\n  const [fam, setFam] = useState<Fam | \"all\">(\"all\");\n  const list = ITEMS.map((it, i) => ({ it, n: i + 1 })).filter(({ it }) => fam === \"all\" || it.f === fam);\n  const chip = `inline-flex min-h-[40px] items-center gap-1.5 whitespace-nowrap rounded-full px-3.5 text-[13px] font-medium transition-colors ${RING}`;\n  return (\n    <section className=\"bg-[#17191d] px-4 py-12 text-slate-100 sm:px-8 sm:py-14\" style={{ fontFamily: '\"Inter Tight\", Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif' }}>\n      <div className=\"mx-auto max-w-6xl\">\n        <header className=\"flex flex-col gap-6 md:flex-row md:items-end md:justify-between\">\n          <div className=\"max-w-3xl\">\n            <p className=\"font-mono text-[12px] uppercase tracking-[0.18em] text-slate-400\">React · Tailwind · HTML</p>\n            <h2 className=\"mt-3 text-[32px] font-semibold leading-[1.05] tracking-[-0.03em] text-white sm:text-[44px]\">Sidebar navigation layouts</h2>\n            <p className=\"mt-4 max-w-xl text-[15px] leading-relaxed text-slate-400\">\n              Six sidebars that each solve a different layout problem: collapsing to icons, two levels of navigation, long nested docs, a phone drawer, a workspace switcher, and a version with no script. Every one works in its frame.\n            </p>\n          </div>\n          <div className=\"flex flex-wrap gap-1.5\" role=\"group\" aria-label=\"Filter sidebars\">\n            {([\"all\", ...FAM_KEYS] as const).map((f) => {\n              const on = fam === f;\n              const count = f === \"all\" ? ITEMS.length : ITEMS.filter((it) => it.f === f).length;\n              return (\n                <button key={f} type=\"button\" aria-pressed={on} onClick={() => setFam(f)} className={`${chip} ${on ? \"bg-white text-slate-900\" : \"bg-white/5 text-slate-200 ring-1 ring-inset ring-white/15 hover:bg-white/10\"}`}>\n                  {f === \"all\" ? \"All\" : FAMILIES[f]}\n                  <span className={`font-mono text-[11px] ${on ? \"text-slate-600\" : \"text-slate-400\"}`}>{count}</span>\n                </button>\n              );\n            })}\n          </div>\n        </header>\n        <div className=\"mt-8 h-[1200px] overflow-y-auto overscroll-contain border-t border-white/10 pr-1 pt-6\" tabIndex={0} aria-label=\"Sidebar examples\">\n          <ul className=\"grid grid-cols-1 gap-5\">\n            {list.map(({ it, n }) => (\n              <Card key={n} item={it} n={n} />\n            ))}\n          </ul>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
