{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"smooth-accordion","type":"registry:ui","title":"Smooth accordion","description":"Accessible FAQ accordion with smooth height animation, a plus to minus icon morph and single or multiple mode.","dependencies":["motion"],"registryDependencies":["utils"],"files":[{"path":"registry/items/smooth-accordion/smooth-accordion.tsx","type":"registry:ui","target":"components/facade/smooth-accordion.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface AccordionItem {\n  /** Unique id. */\n  value: string;\n  /** Question or header text. */\n  title: React.ReactNode;\n  /** Answer or body content. */\n  content: React.ReactNode;\n}\n\nexport interface SmoothAccordionProps {\n  /** Accordion entries. Defaults to a short FAQ example. */\n  items?: AccordionItem[];\n  /** \"single\" keeps one item open at a time. Defaults to \"single\". */\n  type?: \"single\" | \"multiple\";\n  /** Items open on first render. */\n  defaultValue?: string[];\n  /** Controlled open items. */\n  value?: string[];\n  onValueChange?: (value: string[]) => void;\n  /** Heading level used for each header. Defaults to 3. */\n  headingLevel?: 2 | 3 | 4;\n  className?: string;\n  itemClassName?: string;\n}\n\nconst EASE = [0.16, 1, 0.3, 1] as const;\n\nfunction PlusMinus({ open, reduce }: { open: boolean; reduce: boolean }) {\n  return (\n    <span\n      aria-hidden\n      className={cn(\n        \"relative inline-flex size-8 shrink-0 items-center justify-center rounded-full transition-colors duration-300\",\n        open ? \"bg-muted text-foreground\" : \"bg-background text-muted-foreground group-hover/item:text-foreground\",\n      )}\n    >\n      <span className=\"absolute h-[1.5px] w-3.5 rounded-full bg-current\" />\n      <motion.span\n        className=\"absolute h-3.5 w-[1.5px] rounded-full bg-current\"\n        initial={false}\n        animate={{ rotate: open ? 90 : 0, scaleY: open ? 0 : 1 }}\n        transition={reduce ? { duration: 0 } : { duration: 0.4, ease: EASE }}\n      />\n    </span>\n  );\n}\n\nconst DEFAULT_ITEMS: AccordionItem[] = [\n  {\n    value: \"estimate\",\n    title: \"How fast can I get an estimate?\",\n    content: \"Most estimates go out the same day. Send a few photos and your ZIP code and we will reply with a written, flat-rate quote.\",\n  },\n  {\n    value: \"insured\",\n    title: \"Are you licensed and insured?\",\n    content: \"Yes. We are fully licensed, bonded and insured, and we are happy to share certificates before any work starts.\",\n  },\n  {\n    value: \"warranty\",\n    title: \"What does the warranty cover?\",\n    content: \"Labor is covered for two years and materials carry the manufacturer warranty. If something is not right, we come back and fix it.\",\n  },\n];\n\nexport function SmoothAccordion({\n  items = DEFAULT_ITEMS,\n  type = \"single\",\n  defaultValue = [],\n  value,\n  onValueChange,\n  headingLevel = 3,\n  className,\n  itemClassName,\n}: SmoothAccordionProps) {\n  const reduce = useReducedMotion() ?? false;\n  const id = React.useId();\n  const [internal, setInternal] = React.useState<string[]>(defaultValue);\n  const open = value ?? internal;\n  const Heading = `h${headingLevel}` as \"h2\" | \"h3\" | \"h4\";\n\n  const toggle = (v: string) => {\n    const isOpen = open.includes(v);\n    const next = type === \"single\" ? (isOpen ? [] : [v]) : isOpen ? open.filter((x) => x !== v) : [...open, v];\n    if (value === undefined) setInternal(next);\n    onValueChange?.(next);\n  };\n\n  return (\n    <div className={cn(\"flex flex-col gap-1 rounded-[28px] bg-muted p-2 text-foreground\", className)}>\n      {items.map((item) => {\n        const isOpen = open.includes(item.value);\n        const triggerId = `${id}-trigger-${item.value}`;\n        const panelId = `${id}-panel-${item.value}`;\n        return (\n          <div\n            key={item.value}\n            className={cn(\n              \"group/item rounded-[20px] transition-colors duration-300\",\n              isOpen ? \"bg-background\" : \"bg-transparent\",\n              itemClassName,\n            )}\n          >\n            <Heading className=\"m-0\">\n              <button\n                type=\"button\"\n                id={triggerId}\n                aria-expanded={isOpen}\n                aria-controls={isOpen ? panelId : undefined}\n                onClick={() => toggle(item.value)}\n                className={cn(\n                  \"flex w-full items-center justify-between gap-6 rounded-[20px] px-5 py-4 text-left text-[16px] font-medium tracking-[-0.01em] transition-colors sm:px-6 sm:py-5\",\n                  \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring\",\n                  isOpen ? \"text-foreground\" : \"text-foreground/85 hover:text-foreground\",\n                )}\n              >\n                <span>{item.title}</span>\n                <PlusMinus open={isOpen} reduce={reduce} />\n              </button>\n            </Heading>\n            <AnimatePresence initial={false}>\n              {isOpen ? (\n                <motion.div\n                  key=\"panel\"\n                  id={panelId}\n                  role=\"region\"\n                  aria-labelledby={triggerId}\n                  initial={{ height: 0, opacity: 0 }}\n                  animate={{ height: \"auto\", opacity: 1 }}\n                  exit={{ height: 0, opacity: 0 }}\n                  transition={\n                    reduce\n                      ? { duration: 0 }\n                      : { height: { duration: 0.5, ease: EASE }, opacity: { duration: 0.3, ease: EASE } }\n                  }\n                  className=\"overflow-hidden\"\n                >\n                  <div className=\"px-5 pb-5 pr-16 text-[15px] leading-relaxed text-muted-foreground sm:px-6 sm:pb-6 sm:pr-20\">\n                    {item.content}\n                  </div>\n                </motion.div>\n              ) : null}\n            </AnimatePresence>\n          </div>\n        );\n      })}\n    </div>\n  );\n}\n\nexport default SmoothAccordion;\n"}],"categories":["layout"],"meta":{"tier":"free","demo":"import { MessageCircle } from \"lucide-react\";\nimport { SmoothAccordion } from \"./smooth-accordion\";\n\nconst faqs = [\n  {\n    value: \"supplies\",\n    title: \"Do I need to provide cleaning supplies?\",\n    content:\n      \"No. Our team arrives with everything, including HEPA vacuums and plant based products. If you prefer a specific brand, leave it out and we will use it.\",\n  },\n  {\n    value: \"home\",\n    title: \"Do I have to be home during the cleaning?\",\n    content:\n      \"Most clients are not. You can leave a key, share a door code or use a lockbox. Every cleaner is background checked, bonded and insured up to $1M.\",\n  },\n  {\n    value: \"price\",\n    title: \"How is pricing calculated?\",\n    content:\n      \"Flat rates based on bedrooms and bathrooms, starting at $129 for a one bedroom apartment. You see the exact price before you book, no hourly surprises.\",\n  },\n  {\n    value: \"guarantee\",\n    title: \"What if I am not happy with the clean?\",\n    content:\n      \"Tell us within 24 hours and we will come back to re-clean the missed areas for free. If it is still not right, we refund the visit.\",\n  },\n  {\n    value: \"reschedule\",\n    title: \"Can I reschedule or skip a visit?\",\n    content: \"Yes, anytime up to 24 hours before your appointment from your account or by text. No fees.\",\n  },\n];\n\nexport default function Demo() {\n  return (\n    <section className=\"mx-auto grid w-full max-w-4xl gap-8 md:grid-cols-[1fr_1.6fr] md:gap-12\">\n      <div>\n        <p className=\"text-[13px] font-medium uppercase tracking-[0.08em] text-muted-foreground\">Tidy Nest, Denver</p>\n        <h3 className=\"mt-3 font-display text-[32px] font-semibold leading-[1.05] tracking-[-0.03em] sm:text-[40px]\">\n          Questions, answered\n        </h3>\n        <p className=\"mt-4 text-[17px] leading-relaxed text-muted-foreground\">\n          Everything you need to know before your first clean. Still unsure? Our Denver team replies in minutes.\n        </p>\n        <a\n          href=\"#\"\n          className=\"mt-6 inline-flex h-11 items-center gap-2 rounded-full bg-muted px-5 text-[15px] font-medium text-foreground transition-colors hover:bg-foreground/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n        >\n          <MessageCircle className=\"size-4\" aria-hidden />\n          Text us a question\n        </a>\n      </div>\n      <SmoothAccordion items={faqs} defaultValue={[\"supplies\"]} />\n    </section>\n  );\n}\n"}}