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

MenuButton

Open an action menu from a button, with automatic focus management and a custom trigger.

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

Usage

Provide items and a trigger label. disabled prevents opening. The popup uses the same item model as Menu, including nested groups, optional commands, disabled entries and separators. The default trigger is a compact neutral button; projected content replaces its visible label while the native button keeps the menu relationship.

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-button
  [items]="items"
  label="Actions"
  [disabled]="false"
  (itemClick)="selectItem($event)"
  (openChange)="open.set($event)"
/>

Data and content

openChange reports the actual popup state; it is an Output, not an open Input. A leaf command runs before itemClick is emitted and the popup closes. Outside pointer interaction or Escape closes it. neuMenuItem customizes popup item content; ordinary projected content customizes the trigger.

Accessibility and keyboard

Enter, Space or Arrow Down opens and focuses the first available action; Arrow Up can open at the last action. Use the Menu keyboard controls inside the popup. Escape returns focus to the trigger. Custom trigger content needs a clear visible or accessible name and must not contain another button or link.

Key
Action
Tab Focus the enabled trigger.
Enter Open the menu from the trigger; inside the menu, activate the focused action.
Space Open the menu from the trigger; inside the menu, activate the focused action.
ArrowDown From the trigger, open at the first available action; inside, move to the next action.
ArrowUp From the trigger, open at the last available action; inside, move to the previous action.
ArrowRight / ArrowLeft Navigate menu groups according to text direction.
Home / End Reach the first or last available action in the current level.
Escape Close the popup and return focus to the 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
disabledbooleanfalse[disabled]Disables the trigger/navigation. Individual item disabled states belong to items.
itemsNeuMenuItem[][][items]Action data with unique keys; children create groups. Core does not mutate this array.
labelstring'Menu'[label]Visible fallback trigger text when no content is projected.

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
itemClickNeuMenuItem(itemClick)="onItemClick($event)"Emits the activated leaf/action. The optional command runs first; disabled entries do not activate.
openChangeboolean(openChange)="onOpenChange($event)"Reports the actual popup state: true on open, false on close.

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
ng-template[neuMenuItem] Content projection<ng-content select="ng-template[neuMenuItem]" />
*

Projected content

View example
Content projection

Application-provided content.

<ng-content />

Context used: โ€”

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.

Custom trigger content

*

Custom trigger content

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

Popup item content

NeuMenuItemDirective

Popup item 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
No data