Maturity: Developing
The markup may change. Replacing the div, button and
aria-expanded with the platform's own <details> and <summary> is
under consideration. It would need no JavaScript, and it would change the
elements this component emits and the attributes your stylesheet targets.
Usage
<.accordion id="dog-breeds">
<:section title="Golden Retriever">
<p>
Friendly, intelligent, great with families. Origin: Scotland. Needs
regular exercise.
</p>
</:section>
<:section title="Siberian Husky">
<p>
Energetic, outgoing, distinctive appearance. Origin: Northeast Asia.
Loves cold climates.
</p>
</:section>
<:section title="Dachshund">
<p>
Playful, stubborn, small size. Origin: Germany. Enjoys sniffing games.
</p>
</:section>
</.accordion>
This component needs the Doggo.Accordion JavaScript hook for the arrow
keys. See Phoenix LiveView Hooks for
registering it.
Keyboard
Enter or Space - toggle the section of the focused header.
Up and Down - move to the previous or the next header, wrapping at the
ends.
Home and End - first and last header.
Every header is in the tab order, which is what the ARIA Authoring Practices
describe for an accordion. The arrow keys, Home and End need the
colocated hook; the ARIA Authoring Practices list them as optional for an
accordion.