Accordion
A little less noise. Expandable sections for the details that matter.
<div class="accordion">
<div><div>What is Blocks UI?</div><div>An open collection of accessible components and website blocks built with HTML, CSS, and JavaScript.</div></div>
<div><div>Do I need a framework?</div><div>No React, no Vue, no framework required. Just the web platform.</div></div>
<div><div>Can I use it with AEM?</div><div>Yes. Blocks preserve the EDS row-and-column markup and default decorate function contract. Live AEM integration is not yet verified.</div></div>
<div><div>Do I own the code?</div><div>Yes. Copy the files into your project and customize them directly.</div></div>
</div>.accordion details { border-bottom: 1px solid var(--border); }
.accordion summary { padding: 1.15rem 1.5rem 1.15rem 0; cursor: pointer; font-weight: 500; font-size: 14px; }
.accordion details > div { color: var(--muted-foreground); padding: 0 1rem 1.1rem 0; font-size: 14px; }
.accordion.bordered { padding-inline: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); }
.accordion.bordered details:last-child { border-bottom: 0; }export default function decorate(block) {
if (block.querySelector(':scope > details')) return;
[...block.children].forEach((row) => {
const [label, content] = row.children;
if (!label || !content) return;
const details = document.createElement('details');
const summary = document.createElement('summary');
summary.textContent = label.textContent;
const body = document.createElement('div');
body.append(...content.childNodes);
details.append(summary, body);
row.replaceWith(details);
});
}Installation
Run the source CLI from a Blocks UI checkout. This package is not published to npm.
node packages/cli/index.js add accordionOr copy the source files above. Include tokens.css and base.css once in your project.
Usage
Use the authored row-and-column structure, then let the standalone runtime discover and enhance the block.
<div class="accordion">
<div><div>What is Blocks UI?</div><div>An open collection of accessible components and website blocks built with HTML, CSS, and JavaScript.</div></div>
<div><div>Do I need a framework?</div><div>No React, no Vue, no framework required. Just the web platform.</div></div>
<div><div>Can I use it with AEM?</div><div>Yes. Blocks preserve the EDS row-and-column markup and default decorate function contract. Live AEM integration is not yet verified.</div></div>
<div><div>Do I own the code?</div><div>Yes. Copy the files into your project and customize them directly.</div></div>
</div>import decorate from './blocks/accordion/accordion.js';
document.querySelectorAll('.accordion').forEach(decorate);Variants
Choose a variant in the live preview. Add its class to the authored block.
defaultborderedAccessibility & behavior
Native details and summary elements support Enter and Space. Content remains visible in authored HTML when JavaScript is unavailable.
Multiple instances are supported. Layouts adapt to smaller viewports. No npm dependencies are required at runtime.
AEM usage
Copy the canonical CSS and JavaScript into your EDS block folder. Use the same row-and-column authoring structure shown above and let your existing AEM loader call the default decorator.
Standalone verified. EDS markup compatible. Live AEM integration has not been verified.