ACCORDION: Collapsible content panels with toggle headers
VARIANTS: Default | Flush | With Icons
MODES: Multi-open (default) | Exclusive (single-open)
SIZES: Small | Default | Large
Use accordions to organise content into expandable sections — ideal for FAQs, filter panels, settings, and multi-step forms. Each item can be toggled independently, or set to exclusive mode where opening one closes the others. Requires Stimulus controller.
Default: Bordered wrapper with rounded corners. Multiple items can be open at the same time. Click any header to toggle its content. The active header gets a primary tint and the chevron rotates.
The following documents are typically required:
<div class="tw-accordion" data-controller="accordion"><div class="tw-accordion-item">...</div></div>
Exclusive: Only one item can be open at a time. Opening a new item
automatically closes the previously open one. Set with
data-accordion-exclusive-value="true".
<div class="tw-accordion" data-controller="accordion" data-accordion-exclusive-value="true">...</div>
Flush: Add .accordion-flush to remove the outer border and
rounded corners. Ideal for embedding inside cards or other bordered containers where the
accordion should sit flush against the edges.
<div class="tw-accordion tw-accordion-flush">...</div>
Icons: Add a leading icon using .accordion-header-icon
before the header text. Icons help users quickly identify each section's topic.
<button class="tw-accordion-header"><span class="tw-accordion-header-icon"><i class="fa-regular fa-user"></i></span><span>Title</span><i class="fa-solid fa-chevron-down tw-accordion-chevron"></i></button>
States: Add .active to .accordion-item and
.show to .accordion-collapse for items that start expanded.
Add .disabled to .accordion-item to prevent toggling —
the controller sets the native disabled attribute and aria-disabled automatically.
<div class="tw-accordion-item tw-active">...<div class="tw-accordion-collapse tw-show">...</div></div><div class="tw-accordion-item tw-disabled">...</div>
Sizes: Add .accordion-sm or .accordion-lg to the
.accordion wrapper to adjust padding and font sizes across all items.
<div class="tw-accordion tw-accordion-sm">...</div><div class="tw-accordion tw-accordion-lg">...</div>
Accessibility: Accordion headers are native <button> elements
with aria-expanded and aria-controls attributes. Panels have
role="region" and aria-labelledby linking back to their header.
Tab navigates between headers, Enter/Space toggles the focused item. Disabled items receive
the native disabled attribute and aria-disabled="true".
Tab to the headers below, press Enter or Space to toggle:
aria-expanded — Reflects open/closed state on each headeraria-controls — Links each header to its panel by IDrole="region" — Marks panels as navigable landmark regionsaria-labelledby — Links each panel back to its headeraria-disabled — Marks locked items as non-interactive