StealThis .dev

Mega Menu

Full-width multi-column dropdown navigation menu with categories, links, icons, and a featured section.

Open in Lab
vanilla-js css
Targets: JS HTML

Code

Mega Menu

A full-width multi-column dropdown for top-level navigation with grouped links, section icons, and a highlighted featured card. No dependencies.

Features

  • Fixed top navbar with three top-level items
  • “Products” opens a 3-column mega menu with icon links and a featured card
  • “Resources” opens a 2-column menu with grouped link lists
  • Smooth fade + slide-down animation on open
  • Closes on outside click, Escape, or when another trigger is activated
  • Full keyboard navigation: Tab through items, Enter/Space to open, Escape to close

How it works

  1. Each trigger button sets aria-expanded and toggles an .open class on its associated panel
  2. Panels are position: fixed below the navbar, spanning the full width, hidden via opacity: 0 + pointer-events: none until .open
  3. An overlay <div> catches outside clicks to close the active menu
  4. Escape key closes any open menu and returns focus to its trigger

Accessibility

  • Nav landmark with aria-label
  • Trigger buttons use aria-haspopup="true" and aria-expanded
  • Mega panel has role="region" and aria-label
  • All links are keyboard-reachable in DOM order