A simple and accessible accordion component for React & Chakra UI
npm install @chakra-ui/accordionAn accordion is a vertically stacked set of interactive headings that each
contain a title or content snippet representing a section of content.
The headings function as controls that enable users to reveal or hide their
associated sections of content.
``sh
yarn add @chakra-ui/accordion
npm i @chakra-ui/accordion
`
`jsx`
import {
Accordion,
AccordionItem,
AccordionButton,
AccordionPanel,
} from "@chakra-ui/accordion"
- Accordion: manages the global state of all opened accordion items viaAccordionItem
context.
- : manages the state for a single accordion item.AccordionButton
- : the trigger to open/close an accordion item.AccordionPanel
- : the main content area for the accordion item.
By default, only one accordion can be visible at a time, and it can't be
toggled.
Note 🚨: Each accordion button must be wrapped in a heading tag, that is
appropriate for the information architecture of the page.
`jsx
`
To make each accordion toggle (expand/collapse) on click, pass the allowToggle
prop.
`jsx
Section 1 title
Section 2 title
`
To allow multiple accordions to be visible at a time, pass the allowMultiple
prop.
`jsx
Section 1 title
Section 2 title
``
https://www.w3.org/TR/wai-aria-practices/examples/accordion/accordion.html
https://inclusive-components.design/collapsible-sections/
https://github.com/stereobooster/react-accessible-accordion
https://jqueryui.com/accordion/