Accordion

The Accordion component lets users show and hide sections of related content on a page. It is intended to save vertical space by hiding content, reducing scrolling.

Preview

Usage

The accordion uses a custom hook useAccordion, for the collapsible functionality.

Customization With Props

  • accordionList -> This prop is required to be sent by the user. It accepts an array of objects, where each element is an object of the structure:

NOTE: Keep the name of the keys same as above.

  • id -> The id prop is similar to the id attribute in HTML. It allows to provide overall component id.

  • userAccordionStyle -> The custom styling prop which accepts class name(s) for the full accordion section/component.

  • userAccordionBoxStyle -> The custom styling prop which accepts class name(s) for each accordion label containing both the visible and hidden parts.

  • userAccordionTitleStyle -> The custom styling prop which accepts class name(s) for only the visible part inside an accordion label.

  • userAccordionQuesStyle -> The custom styling prop which accepts class name(s) for the question text inside the visible title part of each accordion label.

  • userAccordionSignStyle -> The custom styling prop which accepts class name(s) for the sign used to show/hide hidden text inside the visible title part of each accordion label.

  • userAccordionContentHideStyle -> The custom styling prop which accepts class name(s) for the hidden content inside each accordion label when it's not shown.

  • userAccordionContentShowStyle -> The custom styling prop which accepts class name(s) for the hidden content inside each accordion label when it becomes visible.

Example

Component Code

This is the code for the Accordion component.

Last updated