Test tracking
Only use them when the content is appropriate. If the panels are too long, the user will end up scrolling too
much (esp. on mobile), which negates the whole purpose of using an accordion. For very long panels, using links
to separate pages is preferred.
If you use accordions to replace page steps such as checkout form steps, make sure you stop the default
browser BACK button behavior so that the BACK button would move up a step in the accordion, because this is
the behavior that most users expect, as tests show.
What's a headless CMS?
LINK
The default markup is enhanced using JavaScript so that the buttons are added to the headings. The buttons
should NOT be in the headings by default. The markup should always consider what the component or content would
look like if no Javascript is enabled and therefore the accordion is not functional. The content is most likely
going to be all visible — either as a series of panels with headings or a definition list, depending on the type
of content.
What's special or different about Prismic?
The buttons need to specify which panels they control using
aria-controls
, and they need to reflect
the state of the panel (collapsed/expanded) using
aria-expanded="true/false"
. The panel itself also
should have
aria-hidden
set to true or false if it is hidden or shown, respectively.
The accordion needs to be able to trap keyboard focus when the user is IN the accordion and uses the arrow
keys to traverse the items in it. Tabbing out of the accordion must be enabled.
How is Prismic different from other CMSs?
You can allow one or more panels to be always collapsed or expanded. You can also set a panel to be open by
default (e.g. the first one). All this functionality can be tied to the markup using data attributes as flags.