Accordion
Styled example › — The Clinic's live-theme accordion pattern (CLI-110): uppercase titles, bottom-bordered items, +/− indicator, both group modes.
An accordion is not a separate element in pd-components — it's pd-disclosure with the group attribute, deliberately (SPEC hard rule: attributes over wrapper elements; Base UI's accordion is likewise its collapsible primitive plus grouping, and the current APG Accordion pattern requires no arrow-key navigation, so there is no keyboard machinery a wrapper would add — Tab plus the buttons' native Enter/Space fully satisfy it).
<h3><button commandfor="faq-shipping" command="--pd-toggle">Shipping</button></h3>
<pd-disclosure id="faq-shipping" group="faq">
<p>Free shipping over $50.</p>
</pd-disclosure>
<h3><button commandfor="faq-returns" command="--pd-toggle">Returns</button></h3>
<pd-disclosure id="faq-returns" group="faq">
<p>30-day returns, no questions asked.</p>
</pd-disclosure>Opening any member closes the other open members of the same group (their pd:close stays cancelable). Wrap each trigger in a heading — the component dev-warns on grouped disclosures whose invoker isn't inside h1–h6/[role="heading"], per the APG accordion's heading requirement. Pick the heading level that fits the page outline; style it to taste (the heading wrapper is invisible styling-wise if you want it to be).
Keep one panel open
Add collapsible="false" to the members (and server-render one open):
<h3><button commandfor="spec-materials" command="--pd-toggle">Materials</button></h3>
<pd-disclosure id="spec-materials" group="specs" collapsible="false" open>…</pd-disclosure>
<h3><button commandfor="spec-care" command="--pd-toggle">Care</button></h3>
<pd-disclosure id="spec-care" group="specs" collapsible="false">…</pd-disclosure>The sole open member refuses to close — hide() returns false, the command is a no-op — and its trigger gets aria-disabled="true" (never native disabled: APG keeps the trigger in the Tab sequence so the state is perceivable). The veto and the attribute move automatically when another member opens.
button[commandfor][aria-disabled='true'] {
cursor: default;
opacity: 0.6;
}Animating height
Pure CSS, no measurement: fractional grid rows interpolate (0fr → 1fr is Baseline in all engines), so the panel animates to its natural content height without JavaScript ever measuring anything — content changes are automatically accounted for.
pd-disclosure {
display: grid;
grid-template-rows: 0fr;
transition: grid-template-rows 250ms ease;
}
pd-disclosure[data-state='open'] {
grid-template-rows: 1fr;
@starting-style {
grid-template-rows: 0fr;
}
}
/* The single direct child is the clipped track. */
pd-disclosure > * {
overflow: clip;
min-block-size: 0;
margin-block: 0;
}The close side animates too: component-owned inert lands immediately, while hidden waits until your transition finishes (SPEC §3). Closing content therefore cannot receive focus mid-animation. Reopening removes only inertness the component added; author-supplied inert is preserved. (Why not a measured --pd-panel-height custom property? It structurally can't work: measuring forces the first open style flush before the value exists, so the transition target would resolve to the non-interpolable auto fallback and snap. The grid recipe needs no measurement at all — see SPEC §5.1.)
Screen reader notes
- Panels are announced via the trigger's
aria-expanded; there's noaria-controls(see the disclosure page for the rationale) and norole="region"on panels — APG marks it optional and recommends against it beyond ~6 panels (landmark noise). Add it yourself on a short, prominent accordion if you want jump-to-region navigation. - The group is invisible to assistive tech by design: an accordion is just disclosures whose openness is coordinated.