# Mega Menu

> A wide multi-column dropdown panel under a nav item, opened on hover or keyboard focus.

- Category: [CSS Navigation](https://copy-css.com/category/navigation)
- Tags: dropdown, multi-column, header, hover, focus-within, ecommerce
- Live preview: https://copy-css.com/snippets/mega-menu
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<nav class="mega-menu" aria-label="Main">
  <div class="mega-menu-item">
    <button class="mega-menu-trigger" type="button">Products</button>
    <div class="mega-menu-panel">
      <div>
        <p class="mega-menu-heading">Build</p>
        <a href="#">Site builder</a>
        <a href="#">Forms</a>
        <a href="#">Checkout</a>
      </div>
      <div>
        <p class="mega-menu-heading">Grow</p>
        <a href="#">Email</a>
        <a href="#">Analytics</a>
        <a href="#">SEO tools</a>
      </div>
      <a class="mega-menu-promo" href="#">New: AI site audit</a>
    </div>
  </div>
  <a href="#">Pricing</a>
  <a href="#">Docs</a>
</nav>
```

## CSS

```css
.mega-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  font: 500 14px system-ui, sans-serif;
}

.mega-menu-item {
  position: relative;
}

.mega-menu > a,
.mega-menu-trigger {
  display: block;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #334155;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.mega-menu > a:hover,
.mega-menu-trigger:hover,
.mega-menu-item:focus-within .mega-menu-trigger {
  background: #e2e8f0;
  color: #0f172a;
}

.mega-menu-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  width: min(360px, calc(100vw - 32px));
  margin-top: 8px;
  padding: 16px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 0 0 1px #0f172a14, 0 18px 40px -12px #0f172a40;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

/* Invisible bridge across the gap so hover is not lost */
.mega-menu-panel::before {
  content: "";
  position: absolute;
  top: -10px;
  right: 0;
  left: 0;
  height: 10px;
}

.mega-menu-item:hover .mega-menu-panel,
.mega-menu-item:focus-within .mega-menu-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.mega-menu-heading {
  margin: 0 8px 6px;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mega-menu-panel a {
  display: block;
  padding: 7px 8px;
  border-radius: 8px;
  color: #0f172a;
  text-decoration: none;
}

.mega-menu-panel a:hover {
  background: #f1f5f9;
}

.mega-menu-panel .mega-menu-promo {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 10px 12px;
  background: #eef2ff;
  color: #4338ca;
  font-weight: 600;
}

.mega-menu a:focus-visible,
.mega-menu-trigger:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  .mega-menu-panel { transition: none; }
}
```

## Notes

- This CSS Mega Menu is 107 lines of pure CSS (2.0 KB) with no JavaScript and no dependencies. It uses transitions, transforms, box shadows and CSS Grid.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
