{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "accordion",
  "type": "registry:ui",
  "title": "Accordion",
  "description": "Sections that expand in place in divided, contained and separated styles, with a smooth height and blur transition, built on React Aria.",
  "dependencies": [
    "@remixicon/react@^4.9.0",
    "react-aria-components@^1.17.0"
  ],
  "registryDependencies": [
    "cx"
  ],
  "files": [
    {
      "path": "components/base/accordion/accordion.tsx",
      "content": "\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport {\n  Button as AriaButton,\n  Disclosure as AriaDisclosure,\n  DisclosureGroup as AriaDisclosureGroup,\n  DisclosurePanel as AriaDisclosurePanel,\n  Heading as AriaHeading,\n} from \"react-aria-components\";\nimport type { DisclosureGroupProps as AriaDisclosureGroupProps, DisclosureProps as AriaDisclosureProps } from \"react-aria-components\";\nimport { RiAddLine, RiArrowDownSLine } from \"@remixicon/react\";\nimport { cx, sortCx } from \"@/utils/cx\";\n\n/**\n * Accordion — stacked sections that expand in place: FAQs, settings groups,\n * order details. Built on React Aria's DisclosureGroup and Disclosure, so\n * each header is a real button with aria-expanded, and a collapsed panel is\n * `hidden=\"until-found\"`: find-in-page still reaches its text and opens it.\n *\n *   <Accordion defaultExpandedKeys={[\"billing\"]}>\n *     <AccordionItem id=\"billing\" title=\"How does billing work?\">…</AccordionItem>\n *     <AccordionItem id=\"seats\" title=\"Can I add seats later?\">…</AccordionItem>\n *   </Accordion>\n *\n * Variants: `divided` (hairlines between rows), `contained` (the landing\n * FAQ's tray of cards), and `separated` (one bordered card per item).\n *\n * Motion follows the agent limits card and Tree View: the panel's height\n * eases open over 300ms on cubic-bezier(0.22, 1, 0.36, 1) while its content\n * fades in, drops 4px into place and sharpens from a 4px blur; the indicator\n * turns with it (a chevron flips, a plus turns into a close). React Aria\n * measures the panel and exposes `--disclosure-panel-height`, so this is\n * all CSS. Reduced motion switches every transition off.\n */\n\ntype IconComponent = ComponentType<{ className?: string; \"aria-hidden\"?: boolean | \"true\" | \"false\" }>;\n\nexport type AccordionVariant = \"divided\" | \"contained\" | \"separated\";\n\nconst EASE = \"ease-[cubic-bezier(0.22,1,0.36,1)]\";\n\nconst styles = sortCx({\n  group: {\n    divided: \"flex flex-col divide-y divide-separator-border\",\n    // The landing FAQ: cards on a tray, inverted in dark mode so the cards\n    // stay a step lighter than the page.\n    contained: \"flex flex-col gap-[3px] rounded-[26px] bg-background-secondary-default p-[3px] dark:bg-background-primary-default\",\n    separated: \"flex flex-col gap-2\",\n  },\n  item: {\n    divided: \"\",\n    contained: \"rounded-[23px] bg-background-primary-default dark:bg-background-secondary-default\",\n    // Modal's ground rather than the card surface: in dark mode the inputs\n    // and switch tracks a settings group holds keep an edge against it.\n    separated: \"rounded-2xl border border-border-button-default bg-background-full shadow-xs\",\n  },\n  trigger: {\n    divided: \"rounded-lg py-4\",\n    contained: \"rounded-[23px] px-5 py-4\",\n    separated: \"rounded-2xl px-4 py-3.5\",\n  },\n  content: {\n    divided: \"pb-4\",\n    contained: \"px-5 pb-5\",\n    separated: \"px-4 pb-4\",\n  },\n});\n\ninterface AccordionContextValue {\n  variant: AccordionVariant;\n  indicator: \"chevron\" | \"plus\";\n}\n\nconst AccordionContext = createContext<AccordionContextValue>({ variant: \"divided\", indicator: \"chevron\" });\n\nexport interface AccordionProps extends Omit<AriaDisclosureGroupProps, \"className\" | \"children\"> {\n  variant?: AccordionVariant;\n  /** `chevron` flips to point up; `plus` turns into a close. Default `chevron`. */\n  indicator?: \"chevron\" | \"plus\";\n  className?: string;\n  children: ReactNode;\n}\n\nexport function Accordion({ variant = \"divided\", indicator = \"chevron\", className, children, ...props }: AccordionProps) {\n  return (\n    <AccordionContext.Provider value={{ variant, indicator }}>\n      <AriaDisclosureGroup {...props} className={cx(styles.group[variant], className)}>\n        {children}\n      </AriaDisclosureGroup>\n    </AccordionContext.Provider>\n  );\n}\n\nexport interface AccordionItemProps extends Omit<AriaDisclosureProps, \"className\" | \"children\"> {\n  title: ReactNode;\n  /** Supporting line under the title, e.g. a summary of the settings inside. */\n  description?: ReactNode;\n  /** Remix Icon before the title. */\n  icon?: IconComponent;\n  /** Heading level of the title. Default 3. */\n  headingLevel?: 2 | 3 | 4 | 5 | 6;\n  className?: string;\n  children: ReactNode;\n}\n\nexport function AccordionItem({\n  title,\n  description,\n  icon: Icon,\n  headingLevel = 3,\n  className,\n  children,\n  ...props\n}: AccordionItemProps) {\n  const { variant, indicator } = useContext(AccordionContext);\n  const Indicator = indicator === \"plus\" ? RiAddLine : RiArrowDownSLine;\n\n  return (\n    <AriaDisclosure\n      {...props}\n      className={cx(\"group/item data-[disabled]:opacity-50\", styles.item[variant], className)}\n    >\n      <AriaHeading level={headingLevel} className=\"flex\">\n        <AriaButton\n          slot=\"trigger\"\n          className={({ isFocusVisible }) =>\n            cx(\n              \"group/trigger flex w-full cursor-pointer items-center gap-3 text-start outline-none\",\n              \"disabled:cursor-not-allowed\",\n              isFocusVisible && \"ring-2 ring-border-focus-ring ring-inset\",\n              styles.trigger[variant],\n            )\n          }\n        >\n          {Icon ? <Icon className=\"size-5 shrink-0 text-foreground-icon-secondary\" aria-hidden /> : null}\n          <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n            <span className=\"text-headline-medium text-text-primary\">{title}</span>\n            {description ? <span className=\"text-body-regular text-text-secondary\">{description}</span> : null}\n          </span>\n          <Indicator\n            aria-hidden\n            className={cx(\n              \"size-5 shrink-0 text-foreground-icon-tertiary transition-[rotate,color] duration-300 motion-reduce:transition-none\",\n              EASE,\n              \"group-hover/trigger:text-foreground-icon-secondary group-data-[expanded]/item:text-foreground-icon-primary\",\n              indicator === \"plus\" ? \"group-data-[expanded]/item:rotate-45\" : \"group-data-[expanded]/item:rotate-180\",\n            )}\n          />\n        </AriaButton>\n      </AriaHeading>\n      <AriaDisclosurePanel\n        className={cx(\"h-(--disclosure-panel-height) overflow-clip transition-[height] duration-300 motion-reduce:transition-none\", EASE)}\n      >\n        <div\n          className={cx(\n            \"text-body-regular text-text-secondary\",\n            \"opacity-0 transition-[opacity,translate,filter] duration-300 motion-reduce:transition-none\",\n            \"motion-safe:-translate-y-1 motion-safe:blur-[4px]\",\n            \"group-data-[expanded]/item:translate-y-0 group-data-[expanded]/item:opacity-100 group-data-[expanded]/item:blur-[0px]\",\n            EASE,\n            styles.content[variant],\n          )}\n        >\n          {children}\n        </div>\n      </AriaDisclosurePanel>\n    </AriaDisclosure>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/base/accordion/accordion.tsx"
    }
  ],
  "meta": {
    "docsUrl": "https://www.boardui.com/components/accordion",
    "example": "import { Accordion, AccordionItem } from \"@/components/base/accordion/accordion\";\n\nexport function Example() {\n  return (\n    <Accordion defaultExpandedKeys={[\"billing\"]} className=\"w-full max-w-[560px]\">\n      <AccordionItem id=\"billing\" title=\"How does billing work?\">\n        <p>Plans are billed at the start of each month for every active seat. Seats you add mid-month are prorated, and you can download every invoice from Settings.</p>\n      </AccordionItem>\n      <AccordionItem id=\"plans\" title=\"Can I change plans later?\">\n        <p>Yes. Upgrades apply right away, and downgrades take effect at the end of the current billing period, so you never lose access you have paid for.</p>\n      </AccordionItem>\n      <AccordionItem id=\"data\" title=\"What happens to my data if I cancel?\">\n        <p>Your workspace stays readable for 30 days, so you can export everything. After that it is deleted for good.</p>\n      </AccordionItem>\n    </Accordion>\n  );\n}",
    "snippets": [
      {
        "label": "contained",
        "code": "<Accordion variant=\"contained\" indicator=\"plus\" defaultExpandedKeys={[\"plans\"]}>\n  <AccordionItem id=\"billing\" title=\"How does billing work?\">…</AccordionItem>\n  <AccordionItem id=\"plans\" title=\"Can I change plans later?\">…</AccordionItem>\n  <AccordionItem id=\"data\" title=\"What happens to my data if I cancel?\">…</AccordionItem>\n</Accordion>"
      },
      {
        "label": "separated",
        "code": "import { RiBankCardLine, RiNotification3Line, RiShieldKeyholeLine } from \"@remixicon/react\";\n\n<Accordion variant=\"separated\" allowsMultipleExpanded defaultExpandedKeys={[\"notifications\"]}>\n  <AccordionItem id=\"notifications\" icon={RiNotification3Line} title=\"Notifications\" description=\"Email, push, and Slack\">\n    <Switch defaultSelected>Email me about mentions</Switch>\n    …\n  </AccordionItem>\n  <AccordionItem id=\"security\" icon={RiShieldKeyholeLine} title=\"Security\" description=\"Two-factor sign-in and sessions\">…</AccordionItem>\n  <AccordionItem id=\"billing\" icon={RiBankCardLine} title=\"Billing\" description=\"Managed by your workspace owner\" isDisabled>…</AccordionItem>\n</Accordion>"
      },
      {
        "label": "controlled",
        "code": "const [expanded, setExpanded] = useState<Set<Key>>(new Set([\"billing\"]));\n\n<Button variant=\"secondary\" size=\"small\" onClick={() => setExpanded(new Set(ids))}>Expand all</Button>\n<Button variant=\"secondary\" size=\"small\" onClick={() => setExpanded(new Set())}>Collapse all</Button>\n\n<Accordion allowsMultipleExpanded expandedKeys={expanded} onExpandedChange={setExpanded}>\n  {faq.map((item) => (\n    <AccordionItem key={item.id} id={item.id} title={item.question}>\n      <p>{item.answer}</p>\n    </AccordionItem>\n  ))}\n</Accordion>"
      },
      {
        "label": "rtl",
        "code": "import { DirectionProvider } from \"@/components/foundations/direction/direction\";\n\n<DirectionProvider locale=\"ar\">\n  <Accordion defaultExpandedKeys={[\"billing\"]}>\n    <AccordionItem id=\"billing\" title=\"كيف تعمل الفوترة؟\">…</AccordionItem>\n    <AccordionItem id=\"plans\" title=\"هل يمكنني تغيير الخطة لاحقًا؟\">…</AccordionItem>\n  </Accordion>\n</DirectionProvider>"
      }
    ]
  }
}
