Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

MegaMenu

Combine links, commands and grouped multi-column panels in responsive navigation.

Category
Navigation
Import
@neural-ui/core/mega-menu
Selector
neu-mega-menu
import { NeuMegaMenuComponent } from '@neural-ui/core/mega-menu';

Usage

Each root item has kind: link, command or panel. A link needs routerLink or url; a command needs its callback; a panel contains columns, groups and link/command leaves. Give every level a stable key. orientation chooses horizontal or vertical layout; breakpoint enables mobile navigation and scrollHeight limits the panel height.

Examples

Try the interaction and open Code for the complete implementation.

Examples

Selected: โ€” ยท itemClick: 0 ยท Commands: 0

Try and configure

Change the options, try the result and see the template update. Open Code for the complete data model and implementation.

Try and configure

Selected: โ€” ยท itemClick: 0 ยท Commands: 0

Core options update this template. Item icons, badges and disabled actions belong to the data model shown in Code.

template.html
<neu-mega-menu
  [items]="items"
  ariaLabel="Example navigation"
  orientation="horizontal"
  direction="ltr"
  breakpoint="960px"
  scrollHeight="min(28rem, 70vh)"
  [disabled]="false"
  (itemClick)="selectItem($event)"
  (mobileActiveChange)="mobile.set($event)"
  [menuButtonAriaLabel]="'Toggle example navigation'"
/>

Data and content

itemClick emits activated links or commands, not disclosure-only panels. mobileActiveChange reports the mobile menu state. Core owns disclosure/focus and respects disabled entries; the application owns navigation destinations and command work. Start and End Templates add surrounding content. The Item Template receives item, active, index and level (0 for roots, 3 for leaves), not a callback to execute.

Accessibility and keyboard

Name the navigation and translate menuButtonAriaLabel. Use Tab/Shift+Tab to reach native links and buttons; Enter activates either, while Space activates buttons only. Tab from an open desktop panel trigger enters its first available link or button. Escape closes the panel and restores trigger focus; on the mobile toggle it closes mobile navigation. Arrow keys and Home/End retain browser behavior; this is navigation, not an application menu. Custom Item content remains inside Core links/buttons; Start/End may contain their own accessible controls.

Key
Action
Tab Reach top-level actions, open-panel links and available mobile controls.
Arrow keys Keep native browser scrolling; no arrow-key selection model is added to this navigation.
Home / End Keep native browser behavior; use Tab and Shift+Tab to move between links and buttons.
Enter Activate the focused native link or button, including a panel trigger.
Space Activate the focused button or panel trigger; native links use Enter.
Escape Close the panel and restore focus to its trigger.

API

Inputs and Outputs match the installed package. Named types link to definitions. Each available Template/projection has an executable example.

Inputs

Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.

Name
Type
Default
Template binding
Description
ariaLabelstring'Main navigation'[ariaLabel]Accessible navigation/menu name. Use a label specific to this region.
ariaLabelledBystring | nullnull[ariaLabelledBy]Id of an existing element naming the navigation; takes precedence over ariaLabel.
breakpointstring'960px'[breakpoint]Viewport width threshold for compact mobile presentation, expressed as CSS pixels.
directionNeuTextDirection'ltr'[direction]Text/keyboard direction: ltr or rtl.
disabledbooleanfalse[disabled]Disables the trigger/navigation. Individual item disabled states belong to items.
idstring | undefinedNo default[id]Optional stable host id. Keep ids unique when displaying several menus.
itemsreadonly NeuMegaMenuItem[][][items]Discriminated root entries: link, command or panel with columns/groups/leaves.
menuButtonAriaLabelstring'Toggle navigation'[menuButtonAriaLabel]Accessible mobile toggle name; translate it for your application.
orientationNeuMegaMenuOrientation'horizontal'[orientation]Root layout and keyboard orientation: horizontal or vertical.
scrollHeightstring'min(28rem, 70vh)'[scrollHeight]Maximum panel height; panel content scrolls locally when needed.

Outputs

Listen to an event with (event)="handler($event)". The table explains the data your handler receives and how to use it.

Name
Payload
Template binding
Description
itemClickNeuMegaMenuItem | NeuMegaMenuLeaf(itemClick)="onItemClick($event)"Emits the activated leaf/action. The optional command runs first; disabled entries do not activate.
mobileActiveChangeboolean(mobileActiveChange)="onMobileActiveChange($event)"Reports whether mobile navigation is open; not a controlled-state Input.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

Name
Mechanism
Contract
NeuMegaMenuEndDirectiveView example Public template directive (entrypoint)ng-template[neuMegaMenuEnd]
NeuMegaMenuItemDirectiveView example Public template directive (entrypoint)ng-template[neuMegaMenuItem]
NeuMegaMenuStartDirectiveView example Public template directive (entrypoint)ng-template[neuMegaMenuStart]

Each example demonstrates a different template. Switch between Demo and Code to inspect its implementation, imports and state.

Start content

NeuMegaMenuStartDirective

Start content

Selected: โ€” ยท itemClick: 0 ยท Commands: 0

Root and leaf content

NeuMegaMenuItemDirective

Root and leaf content

Selected: โ€” ยท itemClick: 0 ยท Commands: 0

End content

NeuMegaMenuEndDirective

End content

Selected: โ€” ยท itemClick: 0 ยท Commands: 0

Public Types

Open a type to inspect its definition and interface fields.

Styles and tokens

Use supported public tokens for the component. Icon resolution and surrounding example layout belong to the application. Check both themes and narrow screens.

Specific tokens

This component uses shared theme tokens rather than dedicated component hooks.

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
--neu-border Normal control and cell borders Shared by other Core consumers; scope the override. rgba(15, 23, 42, 0.08)
--neu-primary Brand color for active controls and emphasis Shared by other Core consumers; scope the override. #007aff
--neu-primary-soft Subtle selected or active surface Shared by other Core consumers; scope the override. var(--neu-primary-50)
--neu-surface Main field, header or control surface Shared by other Core consumers; scope the override. #ffffff
--neu-surface-2 Secondary surfaces and alternating rows Shared by other Core consumers; scope the override. #f1f5f9
--neu-text Main text and inherited icon color Shared by other Core consumers; scope the override. #0f172a
--neu-shadow-lg Surface or overlay elevation Shared by other Core consumers; scope the override. 0 10px 30px rgba(15, 23, 42, 0.1), 0 4px 8px rgba(15, 23, 42, 0.04)