Cards
Flexible collections for ideas, articles, and everything worth sharing.
<div class="cards">
<div><div><span class="badge accent">Foundation</span><h3>HTML first.</h3><p>Content that works before JavaScript, and gets better with it.</p><a href="#architecture">Explore the architecture</a></div></div>
<div><div><span class="badge">Your code</span><h3>Make it yours.</h3><p>Copy the source. Change every detail. Ship without a runtime dependency.</p><a href="#installation">See installation</a></div></div>
</div>.cards > ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 1.2rem; }
.cards > ul > li { border: 1px solid var(--border); border-radius: var(--radius); overflow: clip; background: var(--background); }
.cards > ul > li > div { padding: 1.4rem; }
.cards > ul > li > div:has(img) { padding: 0; }
.cards img { aspect-ratio: 16 / 10; width: 100%; object-fit: cover; }
.cards h3 { margin-top: 0; }
.cards p { color: var(--muted-foreground); font-size: 14px; }
.cards.compact > ul > li > div { padding: 1rem; }
.cards.horizontal > ul { grid-template-columns: 1fr; }
.cards.horizontal li { display: grid; grid-template-columns: 1fr 2fr; }export default function decorate(block) {
if (block.querySelector(':scope > ul')) return;
const list = document.createElement('ul');
list.setAttribute('role', 'list');
[...block.children].forEach((row) => {
const item = document.createElement('li');
item.append(...row.childNodes);
list.append(item);
});
block.replaceChildren(list);
}Installation
Run the source CLI from a Blocks UI checkout. This package is not published to npm.
node packages/cli/index.js add cardsOr 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="cards">
<div><div><span class="badge accent">Foundation</span><h3>HTML first.</h3><p>Content that works before JavaScript, and gets better with it.</p><a href="#architecture">Explore the architecture</a></div></div>
<div><div><span class="badge">Your code</span><h3>Make it yours.</h3><p>Copy the source. Change every detail. Ship without a runtime dependency.</p><a href="#installation">See installation</a></div></div>
</div>import decorate from './blocks/cards/cards.js';
document.querySelectorAll('.cards').forEach(decorate);Variants
Choose a variant in the live preview. Add its class to the authored block.
defaulthorizontalcompactAccessibility & behavior
Semantic HTML, visible focus states, shared contrast-aware tokens, and responsive styles provide an accessible foundation. Preserve labels and heading hierarchy when customizing.
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.