An accessible accordion component to help structure large amounts of content on a page
The most important thing to remember when implementing this accordion is that the trigger (the element you click to open a drawer) needs to be a focusable element. In this case, we’re using a button and applying all the ARIA attributes with JavaScript. If JavaScript isn’t enabled, each drawer will be in its natural open state.
* Standalone JS is used on projects that are not set up to handle
ES6. To use this version you will need to download the compiled
JavaScript from the component's dist directory and pull it into your
project. The same process should be
followed with the CSS if it cannot process through the NPM package.
Since version 1.1, the component supports nested accordions. The markup remains the same.
Documentation
Installation
This component accepts two arguments, the selector for the accordion container and an object containing optional callbacks.
npm install @10up/component-accordion --save
API
List of APIs for this component
onCreate
Called after the accordion is initialized on page load