Dropdown
A progressively enhanced disclosure for a short collection of links.
<div><details class="dropdown"><summary class="button-secondary">Explore options ⌄</summary><nav aria-label="Example options"><a href="#profile">Profile</a><a href="#settings">Settings</a><a href="https://github.com/gargadobe/blocks-ui">View source</a></nav></details></div>.dropdown { position: relative; width: max-content; }
.dropdown summary { cursor: pointer; list-style: none; }
.dropdown nav { position: absolute; top: calc(100% + 6px); left: 0; min-width: 180px; border: 1px solid var(--border); background: var(--background); border-radius: var(--radius); padding: 0.4rem; box-shadow: var(--shadow); }
.dropdown nav a { display: block; padding: 0.5rem 0.7rem; text-decoration: none; font-size: 13px; border-radius: calc(var(--radius) - 3px); }
.dropdown nav a:hover { background: var(--secondary); }export default function decorate(root) {
const details = root.querySelector('details');
if (!details) return;
const handler = (event) => { if (event.key === 'Escape') { details.open = false; details.querySelector('summary').focus(); } };
root.addEventListener('keydown', handler);
return () => root.removeEventListener('keydown', handler);
}Installation
Run the source CLI from a Blocks UI checkout. This package is not published to npm.
node packages/cli/index.js add dropdownOr copy the source files above. Include tokens.css and base.css once in your project.
Usage
Use semantic HTML and the shared foundation styles. Interactive primitives also export a decorate function.
<div><details class="dropdown"><summary class="button-secondary">Explore options ⌄</summary><nav aria-label="Example options"><a href="#profile">Profile</a><a href="#settings">Settings</a><a href="https://github.com/gargadobe/blocks-ui">View source</a></nav></details></div>import decorate from './components/dropdown/dropdown.js';
decorate(document.querySelector('.dropdown'));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
Primitives belong inside authored blocks, not as nested EDS blocks. Copy their styles and markup into the parent block implementation.
Standalone verified. EDS markup compatible. Live AEM integration has not been verified.