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

Menu

Present a vertical action list with inline groups, controlled expansion and custom item content.

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

Usage

Build items with unique keys and readable labels. children creates an inline group; separator creates a divider, visible:false removes an entry and disabled prevents activation. icon resolves through your application icon provider. badge and shortcut add compact context; shortcut is a visual hint, not a registered keyboard shortcut.

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-menu
  [items]="items"
  ariaLabel="Example navigation"
  [expandedKeys]="expandedKeys()"
  (expandedKeysChange)="expandedKeys.set($event)"
  (itemClick)="selectItem($event)"
/>

Activate from code

Use activate(item) to trigger an action from your application. An enabled leaf runs its optional command and emits itemClick; a branch changes expansion instead. Disabled, hidden and separator entries cannot be activated.

Activate from code

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

Data and content

Set expandedKeys and accept expandedKeysChange to control the open groups. Omit expandedKeys to use local expansion; inline groups initially expand. Activating a leaf calls its optional command and emits itemClick. Branch activation only proposes expansion. Use a command or itemClick to connect an action to application behavior, including navigation. activate(item) exposes the same guarded action flow for programmatic activation.

Accessibility and keyboard

Tab enters the action list. Up/down, Home/End and typeahead move focus through available items. Enter/Space activate a leaf; left/right expand, enter or return from a group according to text direction. Hidden entries, separators and disabled actions are excluded from keyboard navigation. Custom Templates replace item content, not its native interactive wrapper.

Key
Action
Tab Enter or leave the available menu actions.
ArrowUp / ArrowDown Move through available actions in the current level.
ArrowRight / ArrowLeft Enter or return from a submenu; directions reverse in RTL.
Home Focus the first available action in the level.
End Focus the last available action in the level.
Enter Activate the focused enabled action or open its group.
Space Activate the focused enabled action or open its group.
Aโ€“Z Find available actions by their label.
Escape Close the deepest open submenu; a popup restores trigger focus.

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'Menu bar'[ariaLabel]Accessible navigation/menu name. Use a label specific to this region.
expandedKeysreadonly string[] | undefinedundefined[expandedKeys]Applied branch keys; undefined enables component-owned expansion.
itemsNeuMenuItem[][][items]Action data with unique keys; children create groups. Core does not mutate this array.
itemTemplateTemplateRef<{ $implicit: NeuMenuItem; }> | nullnull[itemTemplate]TemplateRef for item content; receives $implicit: NeuMenuItem and takes precedence over neuMenuItem.

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
expandedKeysChangestring[](expandedKeysChange)="onExpandedKeysChange($event)"Proposes the next branch keys. Update expandedKeys to accept a controlled change.
itemClickNeuMenuItem(itemClick)="onItemClick($event)"Emits the activated leaf/action. The optional command runs first; disabled entries do not activate.

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
itemTemplateView example TemplateRef inputTemplateRef<{ $implicit: NeuMenuItem$1; }> | null
NeuMenuItemDirectiveView example Public template directive (entrypoint)ng-template[neuMenuItem]

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

TemplateRef input

itemTemplate

TemplateRef input

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

Projected item content

NeuMenuItemDirective

Projected item content

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

Public methods

Name
Contract
activateactivate(item: NeuMenuItem$1, originalEvent?: Event): void;

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-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-text-muted Secondary labels and supporting content Shared by other Core consumers; scope the override. #475569
--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)
--neu-shadow-sm Surface or overlay elevation Shared by other Core consumers; scope the override. 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04)