Accordion

The Accordion component displays a vertically stacked set of interactive headings. Each heading reveals or hides its associated content when toggled.

Examples

Here are examples of the Accordion component:

Web design involves creating the visual elements and layout of a website. This includes the structure, color scheme, typography, images, and overall user interface (UI) to ensure an appealing, functional, and user-friendly experience.

Responsive web design is an approach that ensures a website looks good and functions well on all devices, from desktops to tablets and smartphones. It uses flexible layouts, grids, and media queries to adjust content based on the screen size.

Mobile-first design prioritizes the mobile experience when building a website, ensuring it works optimally on smaller screens before scaling up for larger devices. With the majority of internet traffic now coming from mobile devices, it's essential to design for mobile users first.

<accordion> <div class="item"> <button class="default title">Title</button> <div class="content"> <p>Content</p> </div> </div> <div class="item"> <button class="default title">Title</button> <div class="content"> <p>Content</p> </div> </div> </accordion>
Useful Info

Here are some helpful tips for customizing and using the Accordion component:

  • Customize the appearance with CSS variables:
    • --padding-x, --padding-y - Adjust horizontal and vertical padding.
    • --radius - Set the border radius for rounded corners.
    • --margin-bottom - Control spacing between accordion items.
    • --item-bg - Define the background color of accordion items.
    • --transition-duration - Set the speed of opening/closing transitions.
  • Apply the .on-hover class to expand items when hovered.
  • Use the open attribute to make an item expanded by default.
  • ARIA attributes for accessibility are automatically managed; no additional setup is needed.
  • Always use the button element for titles to improve accessibility, and include the .default class to reset default styles.
See Example