Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
<app-context-menu> ├── [app-context-menu-trigger] └── <app-context-menu-content> ├── [app-context-menu-label] (optional) ├── [app-context-menu-group] (optional) │ └── <div app-context-menu-item> | <app-context-menu-checkbox-item> │ ├── [app-context-menu-item-text] (optional) │ └── [app-context-menu-shortcut] (optional) ├── [app-context-menu-radio-group] (optional) │ └── <app-context-menu-radio-item> ├── [app-context-menu-separator] (optional) ├── <app-context-menu-sub> (optional) │ ├── <div app-context-menu-sub-trigger> │ └── <app-context-menu-sub-content> └── <app-context-menu-arrow> (optional)
Examples
Chat Message
Loading...
Default
Loading...
Issue
Loading...
Photo
Loading...
API Reference
<app-context-menu>
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
id | string | undefined | generated | Unique identifier used to create IDs for the menu parts. |
ids | Partial<MenuElementIds> | undefined | — | Overrides generated identifiers for individual parts. |
open | boolean | undefined | — | Open state when controlled. Supports Angular two-way binding. |
defaultOpen | boolean | false | Initial open state when uncontrolled. |
highlightedValue | string | null | undefined | — | Highlighted item value when controlled. Supports Angular two-way binding. |
defaultHighlightedValue | string | null | undefined | null | Initially highlighted item value when uncontrolled. |
loopFocus | boolean | false | Wraps keyboard focus from the last item to the first and vice versa. |
closeOnSelect | boolean | undefined | true | Closes the menu after an item is selected. |
typeahead | boolean | undefined | true | Enables character-based item navigation. |
composite | boolean | undefined | true | Enables composite-widget keyboard and focus behavior. |
positioning | MenuPositioningOptions | undefined | { placement: "bottom-start", gutter: 8 } | Configures floating-element placement and collision handling. |
aria-label | string | undefined | — | Accessible label used when no visible element labels the menu. |
anchorPoint | Point | null | undefined | — | Coordinates used to position a context menu at the pointer location. |
navigate | ((details: MenuNavigateDetails) => void) | null | undefined | activates links | Handles navigation when a menu item represents a link. |
triggerValue | string | null | undefined | — | Active trigger value when controlled. Supports Angular two-way binding. |
defaultTriggerValue | string | null | undefined | null | Initial active trigger value when uncontrolled. |
Use [(open)]="open", [(highlightedValue)]="highlightedValue", and
[(triggerValue)]="triggerValue" for two-way binding, or pair each input with its corresponding
change output when using signals.
Outputs
| Output | Type | Description |
|---|---|---|
openChange | boolean | undefined | Emits the updated controlled open state. |
highlightedValueChange | string | null | undefined | Emits the updated highlighted item value. |
triggerValueChange | string | null | undefined | Emits the updated active trigger value. |
select | MenuSelectionDetails | Emits when an item is selected. |
escapeKeyDown | KeyboardEvent | Emits when Escape is pressed while the menu is open. |
focusOutside | MenuFocusOutsideEvent | Emits when focus moves outside the menu. |
highlightChange | MenuHighlightChangeDetails | Emits details whenever the highlighted item changes. |
interactOutside | MenuInteractOutsideEvent | Emits for an interaction outside the menu. |
openChangeDetails | MenuOpenChangeDetails | Emits detailed information about an open-state change. |
pointerDownOutside | MenuPointerDownOutsideEvent | Emits for a pointer-down event outside the menu. |
requestDismiss | CustomEvent | Emits when another layer requests that this one dismiss. |
triggerValueChangeDetails | MenuTriggerValueChangeDetails | Emits detailed information about a trigger-value change. |
[app-context-menu-trigger]
| Input | Type | Default | Description |
|---|---|---|---|
value | string | undefined | — | Value used to identify this context trigger when activated. |
<app-context-menu-content>
| Input | Type | Default | Description |
|---|---|---|---|
class | string | "" | Additional classes applied to the inner content panel. |
[app-context-menu-group]
| Input | Type | Default | Description |
|---|---|---|---|
id | string | undefined | generated | Identifier shared with the group label. |
<div app-context-menu-item>
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
value | string | required | Unique value that identifies the item. |
disabled | boolean | false | Prevents the item from being highlighted or selected. |
valueText | string | undefined | — | Text used for typeahead when it differs from the rendered content. |
closeOnSelect | boolean | undefined | inherited | Overrides the root close-on-select behavior for this item. |
inset | boolean | false | Adds leading inset spacing. |
variant | "default" | "destructive" | "default" | Controls the item's visual treatment. |
Outputs
| Output | Type | Description |
|---|---|---|
select | void | Emits when this item is selected. |
<app-context-menu-checkbox-item>
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
value | string | required | Unique value that identifies the checkbox item. |
checked | boolean | undefined | — | Checked state when controlled. Supports Angular two-way binding. |
disabled | boolean | false | Prevents the item from being highlighted or selected. |
valueText | string | undefined | — | Text used for typeahead when it differs from the rendered content. |
closeOnSelect | boolean | undefined | inherited | Overrides the root close-on-select behavior for this item. |
inset | boolean | false | Adds leading inset spacing. |
Outputs
| Output | Type | Description |
|---|---|---|
checkedChange | boolean | undefined | Emits the updated checked state. |
[app-context-menu-radio-group]
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
id | string | undefined | generated | Identifier shared with the radio group label. |
value | string | null | undefined | — | Selected radio value. Supports Angular two-way binding. |
Outputs
| Output | Type | Description |
|---|---|---|
valueChange | string | null | undefined | Emits the updated selected radio value. |
valueChangeDetails | MenuValueChangeDetails | Emits details when the radio value changes. |
<app-context-menu-radio-item>
| Input | Type | Default | Description |
|---|---|---|---|
value | string | required | Unique value that identifies the radio item. |
disabled | boolean | false | Prevents the item from being highlighted or selected. |
valueText | string | undefined | — | Text used for typeahead when it differs from the rendered content. |
closeOnSelect | boolean | undefined | inherited | Overrides the root close-on-select behavior for this item. |
inset | boolean | false | Adds leading inset spacing. |
[app-context-menu-label]
| Input | Type | Default | Description |
|---|---|---|---|
inset | boolean | false | Adds leading inset spacing. |
<app-context-menu-sub>
Nested menu root. It accepts the same inputs and emits the same outputs as <app-context-menu>.
<div app-context-menu-sub-trigger>
| Input | Type | Default | Description |
|---|---|---|---|
inset | boolean | false | Adds leading inset spacing. |
<app-context-menu-sub-content>
| Input | Type | Default | Description |
|---|---|---|---|
class | string | "" | Additional classes applied to the inner content panel. |
[app-context-menu-item-text]
| Input | Type | Default | Description |
|---|---|---|---|
value | string | undefined | — | Item value used when the directive is outside an item context. |
disabled | boolean | false | Disabled state used when the directive is outside an item context. |
valueText | string | undefined | — | Typeahead text used when the directive is outside an item context. |
Marker-only Parts
[app-context-menu-shortcut], [app-context-menu-separator], and
<app-context-menu-arrow> do not expose additional inputs or outputs.
Context, Providers, and Utilities
| Export | Angular API |
|---|---|
MenuRootProvider | Directive [menu-root-provider] providing an externally created menu API. |
MenuContext | Structural directive [menu-context] exposing the root API to a template. |
MenuItemContextDirective | Structural directive [menu-item-context] exposing the current item state. |
useMenu(options) | Creates the signal-backed menu machine inside an Angular injection context. |
injectMenuContext() | Injects the nearest menu root context. |
injectMenuContextCarrier() | Injects the context carrier used across portals. |
injectMenuItemContext() | Injects the nearest menu-item context. |
ContextMenuImports | Readonly collection containing the context-menu UI and context helpers. |
Types
| Export | Description |
|---|---|
MenuApi | Connected menu state and actions. |
MenuElementIds | Overrides for generated menu part IDs. |
MenuMachineProps | Configuration accepted by the underlying menu machine. |
MenuPositioningOptions | Floating-menu positioning and collision options. |
MenuSelectionDetails | Details emitted by select. |
MenuHighlightChangeDetails | Details emitted by highlightChange. |
MenuOpenChangeDetails | Details emitted by openChangeDetails. |
MenuTriggerValueChangeDetails | Details emitted by triggerValueChangeDetails. |
MenuFocusOutsideEvent | Event emitted by focusOutside. |
MenuInteractOutsideEvent | Event emitted by interactOutside. |
MenuPointerDownOutsideEvent | Event emitted by pointerDownOutside. |
MenuNavigateDetails | Details supplied to the navigate input. |
MenuValueChangeDetails | Details emitted when a radio-group value changes. |
UseMenuOptions | Options accepted by useMenu. |
UseMenuProps | Menu props supplied by the useMenu context callback. |
UseMenuReturn | Signal-backed menu machine returned by useMenu. |
Angular
React
Solid
Svelte
Vue