Accordion

A compound component for collapsible content sections. Supports both controlled and uncontrolled modes with smooth height animations. Built with Accordion, Accordion.Button, and Accordion.Panel sub-components.

Import

import { Accordion, AccordionButton, AccordionPanel } from '@wavebooking/aqua-fusion';

Preview

Loading preview...

Usage

<Accordion defaultOpen>
  {({ open }) => (
    <>
      <Accordion.Button showChevron>
        <span>Section Title</span>
      </Accordion.Button>
      <Accordion.Panel className="pt-2">
        <p>Collapsible content goes here.</p>
      </Accordion.Panel>
    </>
  )}
</Accordion>

Controlled

const [open, setOpen] = useState(false);

<Accordion open={open} onOpenChange={setOpen}>
  <Accordion.Button showChevron>Toggle</Accordion.Button>
  <Accordion.Panel>Controlled content</Accordion.Panel>
</Accordion>

Props

Accordion

PropTypeDefaultDescription
children*ReactNode | ((props: { open: boolean }) => ReactNode)-Content or render function receiving the open state.
defaultOpenbooleanfalseWhether the accordion is open by default (uncontrolled).
openboolean-Controlled open state.
onOpenChange(open: boolean) => void-Callback when open state changes.
classNamestring-Additional CSS class for the wrapper element.

AccordionButton

PropTypeDefaultDescription
children*ReactNode-Button content.
showChevronbooleanfalseShow a default chevron icon that rotates when open.
classNamestring-Additional CSS class for the button element.

AccordionPanel

PropTypeDefaultDescription
children*ReactNode-Panel content revealed when the accordion is open.
durationnumber200Animation duration in milliseconds.
classNamestring-Additional CSS class for the inner content wrapper.