Static
createInstantiates this component of the given element.
Element to initialize.
AccordionOptions for initialization (allow multiple sections, open sections on initialization)
Static
createPublic function for creating accordion component with default sources from HTML.
array of initialized accordions
Generated using TypeDoc
USA Accordion The USA Accordion component is used to initialize content creator accordion markup with augmented accordion markup.
Default Options
Initialization Examples
The easiest way to use the accordion is to let the NCIDS automatically initialize your accordion HTML.
Just add the following to the top of your main Javascript file and it will add code to your javascript that initializes the Accordion with default options.
If you'd like to initialize the accordion with the default options, you can manually initialize the accordion. Below are examples doing so with the default options, and with custom options.
Default Options
Custom Options
HTML Events
The USA Accordion component will dispatch the following CustomEvent types that can be used to track analytics or other needs when a visitor interacts with the accordion.
Mega Menu Interaction Events
usa-accordion:openAll
- Dispatched when function is called to open all accordion sections.usa-accordion:closeAll
- Dispatched when function is called to close all accordion sections.usa-accordion:section:expand
- Dispatched when a user expands the selected section of the accordion.usa-accordion:section:collapse
- Dispatched when a user collapses the selected currently open section of the accordion.