Search documentation

Search the documentation and open a page.

Displays a menu of actions or options when a user right-clicks a target.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/context-menu

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

InputTypeDefaultDescription
idstring | undefinedgeneratedUnique identifier used to create IDs for the menu parts.
idsPartial<MenuElementIds> | undefined—Overrides generated identifiers for individual parts.
openboolean | undefined—Open state when controlled. Supports Angular two-way binding.
defaultOpenbooleanfalseInitial open state when uncontrolled.
highlightedValuestring | null | undefined—Highlighted item value when controlled. Supports Angular two-way binding.
defaultHighlightedValuestring | null | undefinednullInitially highlighted item value when uncontrolled.
loopFocusbooleanfalseWraps keyboard focus from the last item to the first and vice versa.
closeOnSelectboolean | undefinedtrueCloses the menu after an item is selected.
typeaheadboolean | undefinedtrueEnables character-based item navigation.
compositeboolean | undefinedtrueEnables composite-widget keyboard and focus behavior.
positioningMenuPositioningOptions | undefined{ placement: "bottom-start", gutter: 8 }Configures floating-element placement and collision handling.
aria-labelstring | undefined—Accessible label used when no visible element labels the menu.
anchorPointPoint | null | undefined—Coordinates used to position a context menu at the pointer location.
navigate((details: MenuNavigateDetails) => void) | null | undefinedactivates linksHandles navigation when a menu item represents a link.
triggerValuestring | null | undefined—Active trigger value when controlled. Supports Angular two-way binding.
defaultTriggerValuestring | null | undefinednullInitial active trigger value when uncontrolled.

Outputs

OutputTypeDescription
openChangeboolean | undefinedEmits the updated controlled open state.
highlightedValueChangestring | null | undefinedEmits the updated highlighted item value.
triggerValueChangestring | null | undefinedEmits the updated active trigger value.
selectMenuSelectionDetailsEmits when an item is selected.
escapeKeyDownKeyboardEventEmits when Escape is pressed while the menu is open.
focusOutsideMenuFocusOutsideEventEmits when focus moves outside the menu.
highlightChangeMenuHighlightChangeDetailsEmits details whenever the highlighted item changes.
interactOutsideMenuInteractOutsideEventEmits for an interaction outside the menu.
openChangeDetailsMenuOpenChangeDetailsEmits detailed information about an open-state change.
pointerDownOutsideMenuPointerDownOutsideEventEmits for a pointer-down event outside the menu.
requestDismissCustomEventEmits when another layer requests that this one dismiss.
triggerValueChangeDetailsMenuTriggerValueChangeDetailsEmits detailed information about a trigger-value change.

[app-context-menu-trigger]

InputTypeDefaultDescription
valuestring | undefined—Value used to identify this context trigger when activated.

<app-context-menu-content>

InputTypeDefaultDescription
classstring""Additional classes applied to the inner content panel.

[app-context-menu-group]

InputTypeDefaultDescription
idstring | undefinedgeneratedIdentifier shared with the group label.

<div app-context-menu-item>

Inputs

InputTypeDefaultDescription
valuestringrequiredUnique value that identifies the item.
disabledbooleanfalsePrevents the item from being highlighted or selected.
valueTextstring | undefined—Text used for typeahead when it differs from the rendered content.
closeOnSelectboolean | undefinedinheritedOverrides the root close-on-select behavior for this item.
insetbooleanfalseAdds leading inset spacing.
variant"default" | "destructive""default"Controls the item's visual treatment.

Outputs

OutputTypeDescription
selectvoidEmits when this item is selected.

<app-context-menu-checkbox-item>

Inputs

InputTypeDefaultDescription
valuestringrequiredUnique value that identifies the checkbox item.
checkedboolean | undefined—Checked state when controlled. Supports Angular two-way binding.
disabledbooleanfalsePrevents the item from being highlighted or selected.
valueTextstring | undefined—Text used for typeahead when it differs from the rendered content.
closeOnSelectboolean | undefinedinheritedOverrides the root close-on-select behavior for this item.
insetbooleanfalseAdds leading inset spacing.

Outputs

OutputTypeDescription
checkedChangeboolean | undefinedEmits the updated checked state.

[app-context-menu-radio-group]

Inputs

InputTypeDefaultDescription
idstring | undefinedgeneratedIdentifier shared with the radio group label.
valuestring | null | undefined—Selected radio value. Supports Angular two-way binding.

Outputs

OutputTypeDescription
valueChangestring | null | undefinedEmits the updated selected radio value.
valueChangeDetailsMenuValueChangeDetailsEmits details when the radio value changes.

<app-context-menu-radio-item>

InputTypeDefaultDescription
valuestringrequiredUnique value that identifies the radio item.
disabledbooleanfalsePrevents the item from being highlighted or selected.
valueTextstring | undefined—Text used for typeahead when it differs from the rendered content.
closeOnSelectboolean | undefinedinheritedOverrides the root close-on-select behavior for this item.
insetbooleanfalseAdds leading inset spacing.

[app-context-menu-label]

InputTypeDefaultDescription
insetbooleanfalseAdds 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>

InputTypeDefaultDescription
insetbooleanfalseAdds leading inset spacing.

<app-context-menu-sub-content>

InputTypeDefaultDescription
classstring""Additional classes applied to the inner content panel.

[app-context-menu-item-text]

InputTypeDefaultDescription
valuestring | undefined—Item value used when the directive is outside an item context.
disabledbooleanfalseDisabled state used when the directive is outside an item context.
valueTextstring | 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

ExportAngular API
MenuRootProviderDirective [menu-root-provider] providing an externally created menu API.
MenuContextStructural directive [menu-context] exposing the root API to a template.
MenuItemContextDirectiveStructural 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.
ContextMenuImportsReadonly collection containing the context-menu UI and context helpers.

Types

ExportDescription
MenuApiConnected menu state and actions.
MenuElementIdsOverrides for generated menu part IDs.
MenuMachinePropsConfiguration accepted by the underlying menu machine.
MenuPositioningOptionsFloating-menu positioning and collision options.
MenuSelectionDetailsDetails emitted by select.
MenuHighlightChangeDetailsDetails emitted by highlightChange.
MenuOpenChangeDetailsDetails emitted by openChangeDetails.
MenuTriggerValueChangeDetailsDetails emitted by triggerValueChangeDetails.
MenuFocusOutsideEventEvent emitted by focusOutside.
MenuInteractOutsideEventEvent emitted by interactOutside.
MenuPointerDownOutsideEventEvent emitted by pointerDownOutside.
MenuNavigateDetailsDetails supplied to the navigate input.
MenuValueChangeDetailsDetails emitted when a radio-group value changes.
UseMenuOptionsOptions accepted by useMenu.
UseMenuPropsMenu props supplied by the useMenu context callback.
UseMenuReturnSignal-backed menu machine returned by useMenu.