{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "accordion-nested",
  "title": "Accordion Nested",
  "description": "Two levels of accordion for a help centre, categories outside and questions inside, with independent open states and the question count in each category's name.",
  "registryDependencies": [
    "accordion"
  ],
  "files": [
    {
      "path": "registry/patterns/accordion-nested/accordion-nested.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport {\n  Accordion,\n  AccordionContent,\n  AccordionItem,\n  AccordionTrigger,\n} from \"@/components/ui/accordion\"\n\nexport interface NestedGroup {\n  id: string\n  title: string\n  items: { id: string; title: string; content: React.ReactNode }[]\n}\n\nexport interface AccordionNestedProps {\n  groups: NestedGroup[]\n}\n\n/**\n * Two levels of accordion for a help centre or docs index: categories on the\n * outside, questions inside. Each level is its own accordion, so the open\n * category and the open question are independent; headers at the two levels\n * use different heading levels, so the outline stays correct, and each\n * category says how many questions it holds.\n */\nexport function AccordionNested({ groups }: AccordionNestedProps) {\n  return (\n    <Accordion type=\"single\" collapsible>\n      {groups.map((group) => (\n        <AccordionItem key={group.id} value={group.id}>\n          <AccordionTrigger>\n            {group.title}\n            <span className=\"text-muted-foreground text-xs font-normal\">\n              <span className=\"sr-only\">, </span>\n              {group.items.length} question{group.items.length === 1 ? \"\" : \"s\"}\n            </span>\n          </AccordionTrigger>\n          <AccordionContent className=\"ps-4\">\n            <Accordion type=\"single\" collapsible>\n              {group.items.map((item) => (\n                <AccordionItem key={item.id} value={item.id}>\n                  <AccordionTrigger className=\"py-3 font-normal\">\n                    {item.title}\n                  </AccordionTrigger>\n                  <AccordionContent className=\"text-muted-foreground\">\n                    {item.content}\n                  </AccordionContent>\n                </AccordionItem>\n              ))}\n            </Accordion>\n          </AccordionContent>\n        </AccordionItem>\n      ))}\n    </Accordion>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}