Header
A clear way around. Responsive navigation with a mobile menu.
<div class="header">
<a href="#home"><strong>Plain.</strong></a>
<nav aria-label="Example primary"><a href="#features">Features</a><a href="#pricing">Pricing</a><a href="#about">About</a><a class="button-secondary" href="#get-started">Get started</a></nav>
</div>.header { display: flex; align-items: center; gap: 2rem; padding-block: 1rem; }
.header nav { display: flex; align-items: center; gap: 1.5rem; margin-left: auto; }
.header nav a { text-decoration: none; font-size: 13px; }
.header .header-menu { display: none; }
@media (width < 768px) {
.header { flex-wrap: wrap; }
.header .header-menu { display: inline-flex; margin-left: auto; order: 1; }
.header nav { display: none; width: 100%; order: 2; }
.header.is-open nav { display: flex; flex-direction: column; align-items: start; padding: 1rem; border: 1px solid var(--border); }
}export default function decorate(block) {
const nav = block.querySelector('nav');
if (!nav || block.querySelector('button')) return;
const button = document.createElement('button');
button.type = 'button';
button.textContent = 'Menu';
button.className = 'button-secondary';
nav.id ||= `nav-${crypto.randomUUID()}`;
button.setAttribute('aria-controls', nav.id);
button.setAttribute('aria-expanded', 'false');
button.classList.add('header-menu');
const toggle = () => {
const expanded = button.getAttribute('aria-expanded') !== 'true';
button.setAttribute('aria-expanded', String(expanded));
block.classList.toggle('is-open', expanded);
};
const close = (event) => {
if (event.key === 'Escape' && block.classList.contains('is-open')) { toggle(); button.focus(); }
};
button.addEventListener('click', toggle);
block.addEventListener('keydown', close);
block.prepend(button);
return () => { button.remove(); block.removeEventListener('keydown', close); block.classList.remove('is-open'); };
}Installation
Run the source CLI from a Blocks UI checkout. This package is not published to npm.
node packages/cli/index.js add headerOr 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="header">
<a href="#home"><strong>Plain.</strong></a>
<nav aria-label="Example primary"><a href="#features">Features</a><a href="#pricing">Pricing</a><a href="#about">About</a><a class="button-secondary" href="#get-started">Get started</a></nav>
</div>import decorate from './blocks/header/header.js';
document.querySelectorAll('.header').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.