This is version 4 beta of Forma 36Go back to last stable version 3
Forma 36

Accordion

Accordion

Accordions are a good way to deliver a large amount of information. An accordion is a list of headers that after being clicked reveal or hide more content related to them. The header gives the user a summary of the content and the user decides if they need to see the extended content or not.

Table of contents

How to use Accordions

  • The title prop accepts React nodes, but we recommend that only Typography components are used.
  • Since the whole header is a button, do not use Buttons or Links in the title prop. The only click event that should exist is the header's event.

Component variations

The accordion has two variations that define the alignment of the chevron icon: left or right.

Code examples

Other typographic components can be passed as the accordion's title and anything can be used as the accordion's content. For example:

Content recommendations

  • The title should be a short message that summarize the content of the accordion.
  • Anything can be passed as the content of the accordion, but often organizing it with Texts and Tables would be enough.
  • When using headings, be mindful about the heading levels. The header is a Subheading with h2 tag.

Props

Accordion

NameRequiredDefaultTypeDescription
alignend
"start"
"end"
Specify the alignment of the chevron inside the accordion header
childrenReactNodeChild nodes to be rendered in the component
classNamestringCSS class to be appended to the root element
styleCSSPropertiesAccepts a JavaScript object with camelCased properties rather than a CSS string
testIdcf-ui-accordionstringA [data-test-id] attribute used for testing purposes

AccordionItem

NameRequiredDefaultTypeDescription
alignend
"start"
"end"
Specify the alignment of the chevron inside the accordion header
onCollapseFunctionA function to be called when the accordion item is closed
onExpandFunctionA function to be called when the accordion item is opened
titleAccordion TitleReactNodeThe accordion title
titleElementh2HeadingElementThe heading element that will be used by the AccordionHeader
childrenReactNodeThe children of the AccordionItem are in fact the content of the accordion
classNamestringCSS class to be appended to the root element
styleCSSPropertiesAccepts a JavaScript object with camelCased properties rather than a CSS string
testIdcf-ui-accordion-itemstringA [data-test-id] attribute used for testing purposes