Examples
Definition list
The PF default — renders as <dl> / <dt> /
<dd> for term/definition semantics. Multiple items may be expanded at once.
Single expand
Only one item open at a time. Requires shared Alpine state across items — the model's
singleExpand() switch generates the shared open-index state.
Fixed (multiple expand)
fixed=true caps each expanded body at 9.375rem (PF default)
with overflow scroll. Multiple items can be open simultaneously.
Bordered
bordered=true adds pf-m-bordered — items are separated by
bottom borders and the container has no rounded corners.
Large bordered
displayLg=true with bordered=true — PF.org's "Display size
large": bigger toggle type and inset, here with an inline call-to-action link in the last item's body.
Toggle at start
toggleStart=true flips the toggle icon to the left of the text — PF's
togglePosition='start'.
Documentation
Accordion props
Parameters accepted by
{#include components/data-display/accordion ... /}. Model mode: pass
accordion=<Accordion> built in Java instead — the Java tab on each example shows
the builder. Items are a list of {title, content, expanded?} maps.
| Name | Type | Default | Description |
|---|---|---|---|
* id
|
String | — |
DOM id on the accordion root. Per-item toggle/content ids are derived as
{id}-item-{n}-toggle /
{id}-item-{n}-content.
|
* items
|
List<{title, content, expanded?}> | — |
Each item renders one toggle + content pair. expanded defaults to
false.
|
definitionList
|
boolean |
false
|
Render as <dl>/<dt>/<dd>
(PF default in React). Use when items truly are term/definition pairs.
|
headingLevel
|
h1 | h2 | h3 | h4 | h5 | h6
|
h3
|
Heading element wrapping each toggle (ignored when definitionList=true, which
uses <dt>).
|
bordered
|
boolean |
false
|
Adds pf-m-bordered. PF React's isBordered.
|
displayLg
|
boolean |
false
|
Adds pf-m-display-lg — larger toggle text/padding. PF React's
displaySize='lg'.
|
toggleStart
|
boolean |
false
|
Adds pf-m-toggle-start — toggle icon before text. PF React's
togglePosition='start'.
|
fixed
|
boolean |
false
|
Adds pf-m-fixed to each content panel — caps body at
9.375rem with overflow scroll. PF React's
isFixed on AccordionContent.
|
ariaLabel
|
String | — |
Sets aria-label on the accordion root for AT context when no heading is
nearby.
|
isCustomContent
|
boolean |
false
|
Skips the pf-v6-c-accordion__expandable-content-body wrapper around each
item's content — pass raw HTML in item.content for custom layouts.
|
Divergence from PF React. We expose definitionList as
false-by-default (PF React's asDefinitionList defaults to
true) — most consumers use heading semantics, and PF's own examples are split roughly
50/50, so neither default is wrong. Shorter prop names: bordered,
displayLg, toggleStart,
fixed.
Usage
Heading vs. definition list. Use definitionList=true only when items
genuinely are term/definition pairs (glossary, key facts). Otherwise stick with the default heading shape so screen
readers and document outline tools see proper landmarks.
Pick the right heading level. The default h3 assumes the accordion is
one level below an h2 section heading. Override via
headingLevel when the accordion is shallower or deeper in your document outline —
heading levels should never skip.
Single-expand requires shared state. The runtime template gives each item its own Alpine
expanded flag (independent expand/collapse). For single-expand UX, hand-roll an outer
x-data="{ open: null }" wrapper and gate each toggle on a shared key — see the Single
expand example for the pattern.
Accessibility. Each toggle is linked to its content via
aria-controls + aria-labelledby automatically.
aria-expanded reflects the live Alpine state. Add
ariaLabel
on the root when the accordion isn't preceded by a visible heading.