Accordions
An accordion allows a user to toggle the display of sections of content. The accordion component wraps accordion panels that can be selected and expanded. It accepts children to define the content displayed within.
Interactive Examples
Base
Need more examples? Find a bug?
For even more examples, please take a preview of our development environment built on the popular Storybook platform that is an always up-to-date deploy of this repository's master
branch. All example code on this page can be found in the /components/accordion/__examples__/
folder. Storybook example code can be found in /components/accordion/__docs__/storybook-stories.jsx
.
Property Details
All public, supported component props are listed below. If you believe there is a clearer way to describe a property, please submit a pull request. Property descriptions are built from source code comments (written in Markdown) located within propTypes
objects which are typically found in each component's index.jsx
. Pull requests to update these descriptions can easily be done without cloning this repository by clicking "Edit this file" in the Github user interface.
Name | Type | Required | Default | Description |
---|---|---|---|---|
className | union | CSS class names to be added to the accordion component. Tested with snapshot testing. | ||
id | union | HTML id for accordion component. Tested with snapshot testing. | ||
children | node | The panel content for the Accordion component. Accordion panels should be added as Example:
|
Related Sub-Components
Panel
The panel content for the Accordion component.
Property Details
Name | Type | Required | Default | Description |
---|---|---|---|---|
children | node | The panel content for the Accordion component. Accordion panels should be added as | ||
expanded | bool | Indicates whether item is expanded or not, which should be handled by | ||
id | union | Id of the item belonging to this panel. Tested with snapshot testing. | ||
panelContentActions | node | Component that can be passed as prop to | ||
onKeyDownSummary | func | Callback that will run whenever there is a keydown on the panel button. Function doesn't change the state of the component. | ||
onTogglePanel | func | Callback that will run whenever a panel is toggled. Function should handle state to toggle | ||
refs | shape | Ref callback that will pass in panel's | ||
summary | union | Summary in the span element in the header of this panel. The summary is truncated and so the title element should contain the full text so that it is accessible on hover. Tested with snapshot testing. | ||
title | string | HTML title attribute. Tested with snapshot testing. |