Menu / Dropdown Menu
Keyboard-complete action menu with typeahead, disabled items, links, and destructive styling.
- Selector
- ui-menu
- Package
- @ngnova/ui/menu
Import
import { UiMenuComponent, UiMenuTriggerDirective } from '@ngnova/ui/menu';Usage & variants
Live examples use the public ui-menu API, paired with the exact snippet a product team would paste into an Angular app.
Record actions menu
Keyboard-complete action menu with typeahead, disabled items, links, and destructive styling.
Production guidance
Use these notes to decide when the component belongs in a product workflow and what to verify before shipping.
When to use
Use when several peer actions would clutter the interface or apply to one nearby object.
Watch for
Outside pointer interaction dismisses the menu and all document listeners and typeahead timers are cleaned up.
Product recipes
Apply Menu / Dropdown Menu in distinct, copyable product scenarios—not just an isolated component state.
Record actions
A named menu groups common and destructive actions.
1 2 3
<ui-menu [items]="actions" ariaLabel="Record actions" (itemSelected)="run($event.item)">
<button uiMenuTrigger type="button">Actions</button>
</ui-menu>Account switcher
Provide a labelled trigger and checked state for switching between recently used workspaces.
1 2 3
<ui-menu [items]="workspaceItems" ariaLabel="Switch workspace">
<button uiMenuTrigger uiButton variant="outline">Acme workspace</button>
</ui-menu>API Reference
Inputs and outputs are semver-sensitive public API. Keep examples aligned with this table.
Inputs
items [] readonly UiMenuItem[] Ordered actions, links, disabled states, danger states, and separators.
open false boolean Controlled menu visibility.
align 'start' 'start' | 'end' Aligns the menu edge to the trigger.
ariaLabel 'Actions' string Accessible name describing the action collection.
menuId generated string Stable ID used by the trigger aria-controls relationship.
closeOnSelect true boolean Closes and restores trigger focus after selection.
uiMenuTrigger required directive Marks the projected button that toggles the menu.
| Name | Type | Default | Description |
|---|---|---|---|
items | readonly UiMenuItem[] | [] | Ordered actions, links, disabled states, danger states, and separators. |
open | boolean | false | Controlled menu visibility. |
align | 'start' | 'end' | 'start' | Aligns the menu edge to the trigger. |
ariaLabel | string | 'Actions' | Accessible name describing the action collection. |
menuId | string | generated | Stable ID used by the trigger aria-controls relationship. |
closeOnSelect | boolean | true | Closes and restores trigger focus after selection. |
uiMenuTrigger | directive | required | Marks the projected button that toggles the menu. |
Outputs
openChange boolean Requests a controlled visibility update.
itemSelected UiMenuSelection Emits the selected item and source index.
opened void Emits when the menu opens.
closed void Emits when the menu closes.
| Name | Type | Description |
|---|---|---|
openChange | boolean | Requests a controlled visibility update. |
itemSelected | UiMenuSelection | Emits the selected item and source index. |
opened | void | Emits when the menu opens. |
closed | void | Emits when the menu closes. |
Accessibility
- The trigger receives aria-haspopup="menu", aria-expanded, and aria-controls; the popup uses role="menu" and role="menuitem".
- Disabled commands remain discoverable but cannot receive focus or emit selection.
- Danger styling supplements the visible item label and never acts as the only meaning.
Keyboard behavior
- ArrowDown or ArrowUp opens from the trigger and focuses the first or last enabled item.
- Arrow keys wrap, Home and End jump, printable keys perform buffered typeahead, Escape restores trigger focus, and Tab closes without trapping focus.
Testing guidance
- Use UiMenuHarness to open, enumerate, select, and dismiss actions by visible text.
- Test disabled items, separators, links, destructive state, focus order, wrap, typeahead, outside dismissal, and controlled state.