Mega Menu

Pro

Multi-column dropdown header navigation. Top-level items link directly or open a mega panel: columns of links (headings, descriptions, badges, icons), a tabbed panel, a two-pane cascade or an icon grid, with featured cards, a footer bar and in-panel search. Opens on hover or click, with a hover corridor, animated panel and keyboard support.

</>sv-mega-menu mega menunavigationheaderdropdownmenuecommerce
import { SvMegaMenuComponent } from '@styloviz-pro/mega-menu';

Demo & usage

Basic usage

Pro

Usage example — open the gallery for the full interactive demo.

Pro

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Click to open (touch-friendly)

Pro

Compact + active highlight

Pro

Let the browser navigate (the default)

Pro

When to use

  • Job: destination links — renders real `<a href>` links to global destinations across the site (compare all seven in the “Choosing a navigation pattern” guide under Guides).
  • A storefront / marketing header where a section fans out into many links across columns.
  • You want a featured promo (image + CTA) alongside the link columns.
  • For a simple single-column menu, use a Dropdown Menu instead; for in-page section switching, use Tabs.

Async states

None — this component has nothing to load, so it has no loading, empty or error state to drive.

Inputs

NameTypeDefaultDescription
itemsrequiredreadonly MegaMenuItem[]—Top-level navigation items.
triggerMegaMenuTrigger'hover'How panels open.
sizeMegaMenuSize'md'Nav item size.
activeIdstring''Id of the active item — highlights the matching trigger.
closeDelaynumber150Delay (ms) before a hovered panel closes on mouse-leave.
openDelaynumber100Delay (ms) before hovering an item opens its panel, when no panel is open yet. Switching between items while one is already open is always immediate. Set to `0` to open on the first pointer enter.
mobileBreakpointnumber768Viewport width below which the menu becomes a drawer instead of hover panels. Set to `0` to keep the desktop form at every size.
surfaceIdstring | nullnullNames this menu in the shared navigation-analytics stream when a page has more than one — a static name such as `'primary-nav'`, never a record id. Ignored unless `provideSvNavTelemetry()` is wired up.
mobileMenuLabelstring'Menu'Accessible label for the button that opens the mobile drawer.
navigationMegaMenuNavigation'link'Who navigates when an entry has an `href`: with `'link'`, the app's link adapter (`provideSvLinkAdapter`, as for every kit navigation component), or the browser when none is registered; with `'emit'`, your code, via the outputs. An entry with no `href` always emits.
widthMegaMenuWidth'anchored'How wide an open panel is: sized to its content beside the trigger (`'anchored'`), or spanning this menu's whole `<nav>` with the content in a centred container (`'full'`).
hoverIntentMegaMenuHoverIntent'corridor'How hover opens and keeps a panel: `'corridor'` (the delays plus the safe corridor), `'delay'` (the delays only), or `'none'` (opens on the first pointer enter; `closeDelay` still bridges the gap to the panel).
corridorTolerancenumber6How far behind the point where the pointer left a trigger the corridor's apex sits, in px. More forgives a bigger backwards wobble as the hand sets off; the far edge is always the panel's near side.
activeHrefstring''The `href` of the page the reader is on. Its top-level item is highlighted, the link gets `aria-current="page"`, and its tab or category is the one a panel opens on.
panelToneMegaMenuPanelTone'auto'The panel's surface: follow the page's theme (`'auto'`), always light, always dark, or frosted glass — for a menu in a sticky or fixed header, where the page scrolls underneath it.
recentreadonly MegaMenuLink[][]Recently viewed links, shown as a column in every panel whose item sets `recent: true`. Supply them from your own history or `svNavRecorder`.
mobileLayoutMegaMenuMobileLayout'accordion'What the mobile drawer does with a panel item: expand its links in place (`'accordion'`), or push in a page of its own with a Back button (`'stacked-pages'`).
labelsPartial<SvMegaMenuLabels>{}Every string the menu renders itself. Merged over the `megaMenuPro` labels (`provideSvLabels`).

Outputs

EventPayload typeDescription
linkSelectMegaMenuLinkEmitted when a panel link is activated.
itemSelectMegaMenuItemEmitted when a top-level (link) item is activated.
featuredSelectMegaMenuFeaturedEmitted when the featured promo card is activated and this component cancelled the browser's navigation — same rule as the other two. It exists because the card had **no output at all**: a featured promo with no `href` swallowed the click and closed the menu, which is a dead control in the most prominent slot of the panel.
intentChangeMegaMenuIntent | nullThe safe corridor while the pointer travels from a trigger to its open panel, on every move — and `null` when the approach ends. For drawing it; the menu needs nothing from the listener. Fires only under `hoverIntent="corridor"`.

Customization & theming

  • Hover or click trigger, with a configurable close delay.
  • Swaps to a Drawer below `mobileBreakpoint` — there is no small version of a multi-column panel, so it becomes a different control rather than a squeezed one.
  • Columns with optional headings; per-link description, badge and leading icon.
  • Optional featured promo panel with image, copy and CTA — or several `featuredCards` (`promo` · `stats` · `testimonial`) placed by `featuredLayout` (`side` · `top` · `bottom`).
  • Per-item `layout`: `columns` (the default), `cascade` (categories on the left, their links on the right) or `icon-grid` (`gridColumns` 2 or 3); `tabs` turns a panel into a vertical tab list, each tab with its own columns, featured card and footer.
  • A tinted `footer` strip of links and a call to action; `searchable` puts a filter box at the top of a panel, and `recent` shows the menu's `recent` links as a column of their own.
  • `width` (`anchored` · `full`) for a full-width bar, `panelTone` (`auto` · `light` · `dark` · `glass`), `hoverIntent` (`corridor` · `delay` · `none`), and `activeHref` to mark the active trail from the current URL.
  • In the mobile drawer, `mobileLayout` opens a panel item as an `accordion` (the default) or as `stacked-pages`, one level at a time with a Back button; `panelTone="glass"` is for a sticky or fixed header only.
  • Three sizes and active-item highlighting via `activeId`.
  • `surfaceId` names this instance in the shared navigation-analytics stream (`provideSvNavTelemetry()`): a panel opened is `explore`, a link, top-level item or featured card followed is `jump`, Escape is `escape`. Consent and retention are the sink's; under `retention: 'none'` keys and labels are stripped.

Best practices

  • Do: Group links into columns with short `heading`s; keep each panel to 2–4 columns.
  • Do: Use `trigger="click"` when touch users are a priority — hover panels are desktop-first.
  • Do: Pass `activeId` so the current section stays highlighted as users navigate.
  • Do: Routing through the router? Register `provideSvLinkAdapter()` once at the app root, as for the breadcrumb and sidebar: in the default `link` mode every in-app path (`/…`) goes through it, so a click is a router transition, not a page load. Or set `navigation="emit"` and route from the outputs yourself — they fire only when the component cancelled the browser's own navigation, so `link` mode plus a `router.navigate` listener would navigate twice.
  • Tip: Keep the `href` on every item even in `emit` mode — it is what makes middle-click, ⌘-click and "copy link address" work, and those are never intercepted.
  • Do: It ships its own mobile form: below `mobileBreakpoint` (768 by default) it swaps to a Drawer. Set `mobileBreakpoint="0"` only if your shell already provides a mobile nav.

Accessibility

  • Triggers expose `aria-haspopup` and `aria-expanded`; Escape closes the open panel.
  • Panel links are real anchors and are only in the tab order while their panel is open.
  • Left / Right move along the top-level bar (Home / End to the ends) and across the panel's columns; under `dir="rtl"` — read from the host, so a `dir="rtl"` ancestor counts — both mirror, so the arrow always points where focus goes.
  • Chevron rotation and the featured image are decorative (aria-hidden); focus states are visible in light and dark mode.

Feedback on Mega Menu

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.