Accordion

The Accordion component allows users to display multiple sections of content in a limited space. Each item can be expanded or collapsed by clicking on its header.

Basic Example #

            

HTML

<div class="accordion-container w-50 py-1 px-2 all-border-small"> <div class="accordion"> <div class="accordion-box"> <span class="primary-color on-primary-color">item 1 <i class="fa-solid fa-chevron-down txt-subtitle mr-1"></i></span> <div> <p class="on-primary-color">Content for item 1.</p> </div> </div> </div> <div class="accordion active"> <div class="accordion-box"> <span class="primary-color on-primary-color">item 2 <i class="fa-solid fa-chevron-down txt-subtitle mr-1"></i></span> <div> <p class="on-primary-color">Content for item 2.</p> </div> </div> </div> </div>

⚠️ Warning: To use this code, you need to apply the active class and make changes with JavaScript (JS).

HTML Structure #

Class Description
.accordion-container The main wrapper for the Accordion that contains all the items.
.accordion Each accordion item consists of a header and collapsible content. Add the active class to keep the item expanded by default.
.accordion-box The container for each accordion item’s header and content.
span The clickable header of each item. When clicked, the content of the respective item is toggled (expanded/collapsed).

Customization Options #

Scrollable Accordion #

If you have a lot of content inside the accordion, you can use the scroll-accordion class to set a maximum height and make the content scrollable.