Stacked, collapsible content panels.
A port of the Pines accordion.
<.accordion>
<:item title="Is it accessible?">Yes. It follows the WAI-ARIA disclosure pattern.</:item>
<:item title="Is it styled?">Yes, with Tailwind.</:item>
</.accordion>By default only one panel is open at a time, matching Pines. Pass multiple to allow
several.
Summary
Disclosure
Renders an accordion.
Disclosure
Renders an accordion.
Accessibility
Follows the WAI-ARIA disclosure pattern: each trigger is a <button> carrying
aria-expanded and aria-controls, and each panel is aria-labelledby its trigger.
Note that aria-expanded is bound with x-bind:aria-expanded so it tracks the real state.
Prior to v0.2.0 this component emitted the literal string
aria-expanded="x-bind:aria-expanded='open'", which screen readers announced verbatim.
Panel ids are derived from the component's id, so multiple accordions can share a page —
v0.1.x hardcoded id="accordion-content" on every instance.
Attributes
id(:string) - Defaults tonil.multiple(:boolean) - Allow more than one panel open at once. Defaults tofalse.default_open(:integer) - Zero-based index of the panel to open initially.nilopens none. Defaults tonil.animate(:string) -transitionusesx-transitionand needs nothing beyond Alpine core.collapsegives a true height animation but requires the Alpine Collapse plugin — the component will not animate without it.nonedisables animation.Defaults to
"transition". Must be one of"transition","collapse", or"none".class(:string) - Defaults tonil.Global attributes are accepted.
Slots
item(required) - Accepts attributes:title(:string) (required)subtitle(:string)disabled(:boolean)