Accordion
Demonstration
Code
The Accordion is a group of expandable and collapsible header and content regions intended to consolidate the amount of space content will occupy on a page. Further guidance on Accordions can be found on the U.S. Web Design System (USWDS) site. Within the Opportunity Standard, when implementing multiple region groups stacked on one another, the first region should be open when the user lands on the page. Additionally, more than one region may be open at the same time.
Global Script
The Accordion requires JavaScript for functionality and screen reader accessibility. To initialize the Accordion instance from the global script use the following code:
<script src="https://cdn.jsdelivr.net/gh/nycopportunity/standard@v0.0.20/dist/js/default.js"></script> <script> var Standard = new Default(); Standard.accordion(); </script>
This function will attach the accordion toggling event to the body of the document.
Module Import
For module imports, import the Accordion module from the source.
import Accordion from '@nycopportunity/standard/src/components/accordion/accordion'; new Accordion();