Megamenu

From thedaviddias/ux-patterns-for-developers · View interactive version

Megamenu is an AI agent skill from the GitHub repository thedaviddias/ux-patterns-for-developers. Use when you need to display a large number of links in a single menu.

How to use this skill

Skill file

Megamenu

Display a large number of links in a single menu

What it solves

Megamenu is a large, multi-column dropdown panel that expands from a navigation bar to reveal a structured collection of links, categories, and sometimes promotional content. Unlike standard dropdown menus, megamenus use the full or near-full width of the page to organize many navigation options at once.

Megamenus help users scan large navigation structures without repeated clicking, making them a staple on enterprise, e-commerce, and content-heavy websites.

When to use

Use Megamenu to expose a large set of categorized navigation options in a single, scannable panel.

Common scenarios include:

When to avoid

Implementation workflow

  1. Confirm the pattern matches the problem and constraints before copying the example.
  2. Start from the anatomy and examples in references/pattern.md, then choose the smallest viable variation.
  3. Apply accessibility, performance, and interaction guardrails before layering visual polish.
  4. Use the testing guidance to verify behavior across keyboard, screen reader, responsive, and failure scenarios.

Accessibility guardrails

Do's ✅

Don'ts ❌

Performance guardrails

Target Metrics

Optimization Strategies

Lazy Render Panel Content

const [hasOpened, setHasOpened] = useState(false);
const open = () => { setHasOpened(true); setIsOpen(true); };
// Only render panel DOM after first open
{hasOpened && }

Common mistakes

No Hover Intent Delay

The Problem:

The megamenu opens instantly on mouse enter, causing accidental triggers as users move across the navigation bar.

How to Fix It:

Add a 200-300ms hover intent delay before opening. Use a timer that cancels if the mouse leaves the trigger before the delay completes.

Panel Closes When Moving Mouse to It

The Problem:

A gap between the trigger and the panel causes mouseleave to fire on the trigger before mouseenter fires on the panel, closing the menu.

How to Fix It:

Use a shared close delay (300ms) that is cancelled when the mouse enters the panel. Alternatively, create an invisible "bridge" element connecting the trigger to the panel.

No Keyboard Navigation

The Problem:

Users can only access the megamenu with a mouse. Keyboard users cannot open, navigate, or close the panel.

How to Fix It:

Support Enter/Space to toggle, Escape to close, and Arrow keys or Tab to navigate between links. Return focus to the trigger on close.

Related patterns


For full implementation detail, examples, and testing notes, see references/pattern.md.

Pattern page: https://uxpatterns.dev/patterns/navigation/megamenu

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.