Mega Menu
ProMulti-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.
import { SvMegaMenuComponent } from '@styloviz-pro/mega-menu';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
Click to open (touch-friendly)
Compact + active highlight
Let the browser navigate (the default)
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
| Name | Type | Default | Description |
|---|---|---|---|
| itemsrequired | readonly MegaMenuItem[] | — | Top-level navigation items. |
| trigger | MegaMenuTrigger | 'hover' | How panels open. |
| size | MegaMenuSize | 'md' | Nav item size. |
| activeId | string | '' | Id of the active item — highlights the matching trigger. |
| closeDelay | number | 150 | Delay (ms) before a hovered panel closes on mouse-leave. |
| openDelay | number | 100 | Delay (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. |
| mobileBreakpoint | number | 768 | Viewport width below which the menu becomes a drawer instead of hover panels. Set to `0` to keep the desktop form at every size. |
| surfaceId | string | null | null | Names 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. |
| mobileMenuLabel | string | 'Menu' | Accessible label for the button that opens the mobile drawer. |
| navigation | MegaMenuNavigation | '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. |
| width | MegaMenuWidth | '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'`). |
| hoverIntent | MegaMenuHoverIntent | '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). |
| corridorTolerance | number | 6 | How 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. |
| activeHref | string | '' | 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. |
| panelTone | MegaMenuPanelTone | '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. |
| recent | readonly MegaMenuLink[] | [] | Recently viewed links, shown as a column in every panel whose item sets `recent: true`. Supply them from your own history or `svNavRecorder`. |
| mobileLayout | MegaMenuMobileLayout | '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'`). |
| labels | Partial<SvMegaMenuLabels> | {} | Every string the menu renders itself. Merged over the `megaMenuPro` labels (`provideSvLabels`). |
Outputs
| Event | Payload type | Description |
|---|---|---|
| linkSelect | MegaMenuLink | Emitted when a panel link is activated. |
| itemSelect | MegaMenuItem | Emitted when a top-level (link) item is activated. |
| featuredSelect | MegaMenuFeatured | Emitted 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. |
| intentChange | MegaMenuIntent | null | The 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.