Accordion - Keep React
Table of Contents#
- Default Accordion
- Controlling Collapse Behavior
- Visual Context with Left-Side Icons
- Customizing Icons
- Panels That Stay Open
- Disabled Accordions
- API Reference
Default Accordion#
The Default Accordion Component allows you to craft collapsible content sections. Users can reveal and hide the content by simply clicking on the disclosure button.
Controlling Collapse Behavior#
The collapseAll
property lets you control the initial state of accordion panels. When set to true
, all panels are collapsed by default. Users can then expand individual panels as needed.
Visual Context with Left-Side Icons#
Using the iconPosition="left"
property in the AccordionPanel, you can position icons on the left side of the panel header. This allows you to offer context or indicate the content within the panel.
Customizing Icons#
If you prefer custom icons, you have the freedom to choose your preferred icons for the accordion's open and close states. Utilize the openIcon
and closeIcon
props for this purpose.
Panels That Stay Open#
With the alwaysOpen={true}
property, you can configure all panels to remain expanded. This eliminates the need for users to manually toggle panels, ensuring all content is consistently visible.
Disabled Accordions#
If you need to control which panels users can interact with, the disabled
property on specific AccordionPanel components makes certain panels non-interactive.
API Reference#
Explore the available props for the Accordion component
Property | Description | Type | Default |
---|---|---|---|
alwaysOpen | Keep first panels always open. | boolean | false |
flush | Accordion without outer border and rounded corners. | boolean | false |
collapseAll | Collapse panels by default. | boolean | false |
iconPosition | Position of the arrow icon. | left right | left |
disabled | Disable interaction with the accordion. | boolean | false |