Accordion#
The simplest implementation is to use the HTML5 details and summary elements.
item 1
Something small enough to escape casual notice.item 2
Something small enough to escape casual notice.Properties
css#
.accordion-item
#
Applies the standard margin between the accordion items.
.accordion-button
#
Adds the chevron "
", reacting to the open/close state of the item.Sets the width to 100%. To unset this add the Tailwind utility class w-auto
It does not style the content, consider adding article-title
or section-title
according to your need.
react#
@headlessui/react#
@headlessui/react provides multiple components that can create the accordion pattern.
Use <Popover.Group />
with <Popover />
to create a list of accordion where only one item can be expanded at the same time. Alternatively, use <Disclosure />
to create a single accordion.
To animate the folding of the accordion panels, use the <Transition />
component and the transition-fold-y
transition utility, headover for information on refining the animation.
Properties
@tinka/react with @reach/accordion#
@tinka/react
rely on @reach/accordion to setup accessibility.
Please follow their installation section to setup @reach/accordion
.
AnimatedAccordionPanel#
<AnimatedAccordionPanel />
extends <AccordionPanel />
from @reach/accordion
, it has CSS transition over the panel region.
Properties
Props
name | type | default | description |
---|