Accordion — a WAI-ARIA APG accordion with the Fluxon 2.3.1 composition API.
<.accordion id="faq">
<.accordion_item id="shipping" expanded>
<:header>Shipping</:header>
<:panel>We ship worldwide.</:panel>
</.accordion_item>
<.accordion_item id="returns" icon={false}>
<:header class="font-bold">Returns</:header>
<:panel class="prose">Thirty days, no questions asked.</:panel>
</.accordion_item>
</.accordion>The server renders the complete accessible anatomy and initial state. The
LanternAccordion hook owns toggling, single/multiple-open enforcement, and
the optional ArrowUp/ArrowDown/Home/End header navigation from the APG.
Panels remain in the DOM and use hidden when collapsed, keeping ARIA idrefs
valid while removing collapsed content from the tab order and accessibility
tree. Hook-owned state is restored after LiveView patches.
The accordion is Zag-driven (a @zag-js/accordion state machine, loaded
on demand): the hook root carries data-zag plus data-scope="accordion"
/ data-part anatomy, and Zag owns expanded state, open enforcement, and
keyboard navigation. Item identity is the stable item id. Two modes:
- client (default) — Zag owns the value from the initial
expandedflags. - server-driven (
controlled) — the server value (value, a list of expanded item ids) is truth; toggles flow out throughon_change, patches flow in.
Summary
Functions
Attributes
id(:string) - Stable accordion id. A unique id is generated when omitted.class(:any) - Extra classes merged onto the accordion root. Defaults tonil.multiple(:boolean) - Allow more than one item to be expanded at once. Defaults tofalse.prevent_all_closed(:boolean) - Keep at least one enabled item expanded. Defaults tofalse.animation_duration(:integer) - Expand/collapse indicator transition duration in milliseconds. Defaults to300.controlled(:boolean) - Server-driven value:valueis truth, patches flow into the machine. Defaults tofalse.value(:list) - Expanded item ids forcontrolledmode (client mode ignores it). Defaults tonil.on_change(:string) - Server event pushed on toggle (lantern:accordion:set-valuereplies). Defaults tonil.on_change_client(:string) - Bubbling DOM CustomEvent dispatched on toggle. Defaults tonil.- Global attributes are accepted. Arbitrary HTML/
phx-*attributes passed through.
Slots
inner_block(required) - One or moreaccordion_item/1components.
Attributes
id(:string) - Stable item id used to connect its header and panel. A unique id is generated when omitted.class(:any) - Extra classes merged onto the item root. Defaults tonil.expanded(:boolean) - Whether this item starts expanded. Defaults tofalse.icon(:boolean) - Whether to render the built-in chevron. Defaults totrue.- Global attributes are accepted. Arbitrary HTML/
phx-*attributes passed through.
Slots
header(required) - Always-visible header content. Accepts attributes:class(:any) - Extra classes merged onto the header button.
panel(required) - Expandable panel content. Accepts attributes:class(:any) - Extra classes merged onto the panel content wrapper.