Keep a submenu open while moving to it
menuAim()Move diagonally from Products towards the lower links, then try moving directly down. Click a trigger or use Enter to activate immediately.
Desktop check: The diagonal hover behavior can only be checked with a desktop mouse or trackpad. Click and keyboard activation still work on touch devices.
Products selected
<div id="your-component">
<nav class="menu-demo" data-ix="menu-aim" data-ix-side="right" aria-label="Example navigation"><div class="triggers"><button data-ix-menu-trigger="products" aria-expanded="true" aria-controls="products">Products ›</button><button data-ix-menu-trigger="solutions" aria-expanded="false" aria-controls="solutions">Solutions ›</button><button data-ix-menu-trigger="resources" aria-expanded="false" aria-controls="resources">Resources ›</button></div><div class="menu-panel" id="products" data-ix-menu-panel="products"><b>Products</b><a href="#example">Overview</a><a href="#example">Analytics</a><a href="#example">Integrations</a><a href="#example">Developer tools</a></div><div class="menu-panel" id="solutions" data-ix-menu-panel="solutions" hidden><b>Solutions</b><a href="#example">Business</a><a href="#example">Teams</a><a href="#example">Enterprise</a></div><div class="menu-panel" id="resources" data-ix-menu-panel="resources" hidden><b>Resources</b><a href="#example">Guides</a><a href="#example">Documentation</a></div></nav><p class="demo-status" aria-live="polite">Products selected</p>
</div>import * as kit from 'subtly';
// Start once at application level.
const interactions = kit.createInteractions();
interactions.start();
const el = document.querySelector('#your-component');
const listeners = new AbortController();
const { signal } = listeners;
const status = text => {
el.querySelector('.demo-status').textContent = text;
};
// Local simulation only. Replace with your real data operation.
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
function setup() {
const nav = el.querySelector('nav');
// The adapter emits intent. This component controls visibility.
nav.addEventListener('ix:menu-change', ({ detail }) => {
for (const panel of nav.querySelectorAll('[data-ix-menu-panel]')) {
panel.hidden = panel.dataset.ixMenuPanel !== detail.key;
}
for (const trigger of nav.querySelectorAll('[data-ix-menu-trigger]')) {
trigger.setAttribute('aria-expanded', String(trigger.dataset.ixMenuTrigger === detail.key));
}
status(detail.key + ' selected');
}, { signal });
}
const stop = setup();
// Call when this component is removed.
function cleanup() {
listeners.abort();
stop?.();
interactions.stop();
}