Menu
All plugins

Accordion for Bricks

An accessible accordion with a smooth open and close. Each item is a native details element, so it works without JavaScript; the script only adds the animation. Put any Bricks elements inside an item. The same script also animates any button and panel pair, so you can use it for menu sections.

Open the live demo

The element

  • Add the Accordion element. Each item has a heading and a content area. Add items with the plus in the structure panel, and put any elements in the content area, even another accordion.
  • Items start: all closed, first open or all open.
  • Only one open at a time: opening an item closes the others.
  • Animate opening and closing with a time you choose. Visitors who prefer reduced motion get no animation.
  • Style it as lines or cards, with a chevron, plus and minus or no marker. Colours, sizes, line, corner radius and spacing all have controls.
  • Each item can have an icon next to its heading: add an icon element inside the heading and give it the class acdn-icon.

Using it for menus and other panels

Any button that controls a hidden panel can have the same animation.

  • Wrap the buttons and panels in an element with the attribute data-acdn-group. Add data-acdn-single="1" if only one should stay open.
  • Give each button the attribute data-acdn-trigger, aria-expanded="false" and aria-controls with the ID of its panel.
  • Give the panel that ID and the hidden attribute.
  • Optional: data-acdn-dur on the group sets the time in milliseconds.

For developers

  • An acdn:toggle event fires on the button when a panel opens or closes, with detail.open and detail.panel.
  • ACDN.set(button, true or false) opens or closes one from your own script. ACDN.refresh() picks up groups added after the page loaded.

Good to know

  • Without JavaScript the items still open and close, but button and panel groups need the script.
  • Clicking again during the animation reverses it from where it is.