Atoms / Accordion

Accordion

Collapsibles stacked: one open at a time, or several. Up and Down move between headers.

import { Accordion } from "@forgeron/ui";
/01 → Faq
In the EU, on Cloudflare.
import { Accordion } from "@forgeron/ui";

export default function Faq() {
  return (
    <div style={{ width: "min(100%, 480px)" }}>
      <Accordion
        defaultValue={["data"]}
        items={[
          {
            value: "data",
            title: "Where is my data stored?",
            content: "In the EU, on Cloudflare.",
          },
          {
            value: "export",
            title: "Can I export it?",
            content: "Yes: CSV and JSON, at any time.",
          },
          {
            value: "soon",
            title: "Single sign-on",
            hint: "Soon",
            content: "Planned.",
            disabled: true,
          },
        ]}
      />
    </div>
  );
}
/02 → Multiple
Name, photo, language.
Email and in-app.
import { Accordion } from "@forgeron/ui";

export default function Multiple() {
  return (
    <div style={{ width: "min(100%, 480px)" }}>
      <Accordion
        multiple
        defaultValue={["a", "b"]}
        items={[
          { value: "a", title: "Profile", content: "Name, photo, language." },
          { value: "b", title: "Notifications", content: "Email and in-app." },
          { value: "c", title: "Security", content: "Password and sessions." },
        ]}
      />
    </div>
  );
}
API → Props
PropTypeDefaultDescription
itemsAccordionItem[]—{ value, title, hint?, content, disabled? }.
value / defaultValuestring[]—Controlled or not. The values of the open sections.
onChange(value: string[]) => void—On every change.
multiplebooleanfalseSeveral open at once.
headingLevel1–63The level of the headings.
disabledboolean—Not editable.
classNamestring—Extra classes.