Const// Listening for open/close events
const accordion = document.querySelector('umd-element-accordion-item');
accordion.addEventListener('accordion:open', () => console.log('opened'));
accordion.addEventListener('accordion:close', () => console.log('closed'));
<umd-element-accordion-item>
<p slot="headline">Click to expand</p>
<div slot="text">
<p>Hidden content revealed when expanded</p>
</div>
</umd-element-accordion-item>
<!-- Dark theme with default open state -->
<umd-element-accordion-item data-theme="dark" data-visual-open="true">
<span slot="headline">Click to collapse</span>
<div slot="text">
<p>Content revealed as expanded</p>
</div>
</umd-element-accordion-item>
Accordion Item
Creates an expandable/collapsible content container with smooth animations and theme variations.
Custom Element
<umd-element-accordion-item>Slots
headline- The clickable header (required, accepts: span, p)text- The expandable content (required, accepts: div, p)body- Deprecated: Usetextslot insteadAttributes
data-theme- Color theme options:light- Light theme stylingdark- Dark theme stylingdata-visual-open- Initial visual state:true- Opens accordion on loadfalse- Closes accordion on loadObserved Attributes
data-visual-open- When changed to "true", opens accordion with animation; when changed to "false", closes with animationresize- When set to "true", re-evaluates accordion height without animationDispatched Events
Both events bubble and are
composed: true(they cross the Shadow DOM boundary), and fire on the host element for every toggle — whether triggered by a header click or a programmaticdata-visual-openchange. They do not fire for the initial open state set on load.accordion:open— fired when the item opensaccordion:close— fired when the item closes