Gallery
Let your images tell the story with an adaptive, spacious gallery.
<div class="gallery">
<div><div><img src="https://images.unsplash.com/photo-1441974231531-c6227db76b6e?auto=format&fit=crop&w=1000&q=80" alt="Sunlight filtering through a green forest" width="1000" height="500" loading="lazy"></div></div>
<div><div><img src="https://images.unsplash.com/photo-1472396961693-142e6e269027?auto=format&fit=crop&w=600&q=80" alt="Deer standing in a sunlit woodland" width="600" height="450" loading="lazy"></div></div>
<div><div><img src="https://images.unsplash.com/photo-1447752875215-b2761acb3c5d?auto=format&fit=crop&w=600&q=80" alt="A quiet path through dense forest" width="600" height="450" loading="lazy"></div></div>
</div>.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); }
.gallery > div:first-child { grid-column: 1 / -1; }
.gallery > div:first-child img { aspect-ratio: 2 / 1; }
@media (width < 640px) { .gallery { grid-template-columns: 1fr; } }export default function decorate(block) {
block.querySelectorAll('img').forEach((image) => { image.loading ||= 'lazy'; image.decoding = 'async'; });
}Installation
Run the source CLI from a Blocks UI checkout. This package is not published to npm.
node packages/cli/index.js add galleryOr 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="gallery">
<div><div><img src="https://images.unsplash.com/photo-1441974231531-c6227db76b6e?auto=format&fit=crop&w=1000&q=80" alt="Sunlight filtering through a green forest" width="1000" height="500" loading="lazy"></div></div>
<div><div><img src="https://images.unsplash.com/photo-1472396961693-142e6e269027?auto=format&fit=crop&w=600&q=80" alt="Deer standing in a sunlit woodland" width="600" height="450" loading="lazy"></div></div>
<div><div><img src="https://images.unsplash.com/photo-1447752875215-b2761acb3c5d?auto=format&fit=crop&w=600&q=80" alt="A quiet path through dense forest" width="600" height="450" loading="lazy"></div></div>
</div>import decorate from './blocks/gallery/gallery.js';
document.querySelectorAll('.gallery').forEach(decorate);Variants
Choose a variant in the live preview. Add its class to the authored block.
defaultAccessibility & 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.