{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "faq-accordion",
  "title": "FAQ accordion",
  "description": "A question-and-answer accordion whose organic, hand-cut plus turns its upright bar flat into a minus as the answer unblurs open beneath it.",
  "dependencies": [
    "motion",
    "radix-ui"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/items/faq-accordion/faq-accordion.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Accordion as AccordionPrimitive } from \"radix-ui\";\nimport { motion, useReducedMotionConfig } from \"motion/react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport type AccordionEntry = {\n  /** Stable id; also the value reported by `onValueChange`. */\n  id: string;\n  question: React.ReactNode;\n  answer: React.ReactNode;\n  disabled?: boolean;\n};\n\ntype SharedProps = {\n  /** The questions and answers, in order. */\n  items: AccordionEntry[];\n  /** Side of the plus/minus mark, in pixels. Defaults to 24. */\n  iconSize?: number;\n  /** Disables every item. */\n  disabled?: boolean;\n  className?: string;\n};\n\ntype SingleProps = SharedProps & {\n  /** One item open at a time (default). */\n  type?: \"single\";\n  /** Whether the open item can be closed again by pressing it. Defaults to true. */\n  collapsible?: boolean;\n  /** The open item's id, when controlled. `\"\"` closes everything. */\n  value?: string;\n  defaultValue?: string;\n  onValueChange?: (value: string) => void;\n};\n\ntype MultipleProps = SharedProps & {\n  /** Any number of items open at once. */\n  type: \"multiple\";\n  collapsible?: never;\n  value?: string[];\n  defaultValue?: string[];\n  onValueChange?: (value: string[]) => void;\n};\n\nexport type FaqAccordionProps = SingleProps | MultipleProps;\n\n/**\n * One soft, hand-cut bar (viewBox 0 0 24 4). The plus is two of them; opening\n * an item turns the upright one flat until the two read as a single minus.\n */\nconst BAR =\n  \"M23.9941 1.99953C24.0205 2.26456 23.9549 2.54436 23.7803 2.80742C23.4141 3.35816 22.8098 3.53944 22.1716 3.49313C21.435 3.43993 20.6984 3.31481 19.9766 3.16111C18.6188 2.87244 14.1324 2.67934 11.9999 2.59362C9.86733 2.67934 5.37996 2.87244 4.02317 3.16111C3.30032 3.31481 2.56478 3.43993 1.82711 3.49313C1.18999 3.53944 0.584621 3.35816 0.219493 2.80742C0.0438085 2.54436 -0.0207503 2.26554 0.00570827 2.00052C-0.0207503 1.73549 0.0438085 1.45569 0.219493 1.19264C0.584621 0.641899 1.18999 0.460618 1.82711 0.506923C2.56478 0.560125 3.30032 0.685249 4.02317 0.838943C5.37996 1.12761 9.86733 1.31973 11.9999 1.40643C14.1324 1.31973 18.6188 1.12761 19.9766 0.838943C20.6984 0.685249 21.435 0.560125 22.1716 0.506923C22.8098 0.460618 23.4141 0.641899 23.7803 1.19264C23.9549 1.45569 24.0205 1.73451 23.9941 1.99953Z\";\n\nfunction PlusMinusIcon({ open, size, reduceMotion }: { open: boolean; size: number; reduceMotion: boolean }) {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      width={size}\n      height={size}\n      viewBox=\"0 0 24 24\"\n      fill=\"currentColor\"\n      className=\"shrink-0\"\n    >\n      <g transform=\"translate(12 12) scale(0.85) translate(-12 -12)\">\n        <path d={BAR} transform=\"translate(0 10)\" />\n        {/* The upright bar: 90° is a plus, 0° lies on the flat bar as a minus. */}\n        <motion.g\n          initial={false}\n          animate={{ rotate: open ? 0 : 90 }}\n          transition={reduceMotion ? { duration: 0 } : { duration: 0.45, ease: \"easeInOut\" }}\n          style={{ transformBox: \"view-box\", transformOrigin: \"12px 12px\" }}\n        >\n          <path d={BAR} transform=\"translate(0 10)\" />\n        </motion.g>\n      </g>\n    </svg>\n  );\n}\n\nfunction toOpenList(value: string | string[] | undefined): string[] {\n  if (Array.isArray(value)) return value;\n  return value ? [value] : [];\n}\n\n/**\n * A question-and-answer list. Each question carries an organic plus whose\n * upright bar turns flat into a minus as the answer unblurs open beneath it.\n *\n * The open set lives here (or with the caller, when `value` is passed), so the\n * mark and the reveal read it directly rather than watching the DOM.\n */\nexport function FaqAccordion(props: FaqAccordionProps) {\n  const { items, iconSize = 24, disabled, className } = props;\n  const reduceMotion = Boolean(useReducedMotionConfig());\n  const controlled = props.value !== undefined;\n  const [uncontrolled, setUncontrolled] = React.useState<string[]>(() => toOpenList(props.defaultValue));\n  const open = controlled ? toOpenList(props.value) : uncontrolled;\n\n  const list = items.map((item) => {\n    const isOpen = open.includes(item.id);\n    return (\n      <AccordionPrimitive.Item\n        key={item.id}\n        value={item.id}\n        disabled={item.disabled}\n        className=\"border-b border-rule last:border-b-0\"\n      >\n        <AccordionPrimitive.Header className=\"flex\">\n          <AccordionPrimitive.Trigger\n            className={cn(\n              \"flex flex-1 cursor-pointer items-start justify-between gap-4 rounded-inset py-4 text-left\",\n              \"font-heading text-lg leading-snug font-light tracking-[-0.03em] text-ink\",\n              \"transition-opacity duration-200 hover:opacity-80 motion-reduce:transition-none\",\n              \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none\",\n              \"disabled:cursor-not-allowed disabled:opacity-50\",\n            )}\n          >\n            <span className=\"min-w-0\">{item.question}</span>\n            <span className=\"flex h-[1.375em] items-center\">\n              <PlusMinusIcon open={isOpen} size={iconSize} reduceMotion={reduceMotion} />\n            </span>\n          </AccordionPrimitive.Trigger>\n        </AccordionPrimitive.Header>\n        {/* Kept mounted so the height can animate both ways; `inert` keeps a closed answer out of reach. */}\n        <AccordionPrimitive.Content forceMount inert={!isOpen} className=\"overflow-hidden\">\n          <motion.div\n            initial={false}\n            animate={\n              isOpen\n                ? { height: \"auto\", opacity: 1, filter: \"blur(0px)\" }\n                : { height: 0, opacity: 0, filter: reduceMotion ? \"blur(0px)\" : \"blur(4px)\" }\n            }\n            transition={\n              reduceMotion\n                ? { duration: 0 }\n                : {\n                    height: { duration: 0.3, ease: \"easeOut\" },\n                    opacity: { duration: 0.2, delay: 0.1 },\n                    filter: { duration: 0.15, delay: 0.05 },\n                  }\n            }\n            className=\"overflow-hidden\"\n          >\n            <div className=\"pb-4 font-body text-base leading-relaxed font-light text-foreground\">{item.answer}</div>\n          </motion.div>\n        </AccordionPrimitive.Content>\n      </AccordionPrimitive.Item>\n    );\n  });\n\n  const rootClass = cn(\"w-full\", className);\n\n  if (props.type === \"multiple\") {\n    const { onValueChange } = props;\n    return (\n      <AccordionPrimitive.Root\n        type=\"multiple\"\n        value={open}\n        disabled={disabled}\n        onValueChange={(next) => {\n          if (!controlled) setUncontrolled(next);\n          onValueChange?.(next);\n        }}\n        className={rootClass}\n      >\n        {list}\n      </AccordionPrimitive.Root>\n    );\n  }\n\n  const { collapsible = true, onValueChange } = props;\n  return (\n    <AccordionPrimitive.Root\n      type=\"single\"\n      collapsible={collapsible}\n      value={open[0] ?? \"\"}\n      disabled={disabled}\n      onValueChange={(next) => {\n        if (!controlled) setUncontrolled(next ? [next] : []);\n        onValueChange?.(next);\n      }}\n      className={rootClass}\n    >\n      {list}\n    </AccordionPrimitive.Root>\n  );\n}\n\nexport default FaqAccordion;\n",
      "type": "registry:block"
    }
  ],
  "meta": {
    "kind": "pattern",
    "whenToUse": "Use for FAQs and other short, scannable question lists where each answer is a paragraph or two. Do not use it to hide primary content or long forms; anything most readers need should be visible without a press.",
    "origin": {
      "project": "Steeze",
      "path": "src/components/ui/accordion.jsx + trih-icons.jsx + faq-section.jsx"
    },
    "credits": [
      {
        "name": "The Rest Is History club FAQ: plus and minus bar artwork (the SVG path matches therestishistory.com/club exactly)",
        "url": "https://therestishistory.com/club",
        "license": "unknown"
      },
      {
        "name": "shadcn/ui Accordion (Root, Item, Trigger and Content structure over Radix)",
        "url": "https://ui.shadcn.com/docs/components/accordion",
        "license": "MIT"
      }
    ]
  },
  "type": "registry:block"
}
