Blazorise ContextMenu component

Provides a contextual menu that can be opened from a right-click target or programmatically.

API

Parameters

Parameter Description TypeDefault
ChildContent

Specifies the content to be rendered inside this ContextMenu.

RenderFragmentnull
CloseOnClick

Closes the menu when a regular item is clicked.

booltrue
CloseOnEscape

Closes the menu when pressing the Escape key.

booltrue
CloseOnOutsideClick

Closes the menu when clicking outside of it.

booltrue
Disabled

Prevents the menu from opening through its observed target.

boolfalse
SubmenuHoverCloseDelay

Delay in milliseconds before hiding a hover-opened submenu after the mouse leaves it.

int300
SubmenuTrigger

Defines which pointer interactions can open or close nested submenus.

Possible values:None, Click, Hover, All

DropdownTriggerdefault(DropdownTrigger)
TargetId

Specifies an element id that opens this context menu when right-clicked.

string
TargetSelector

Specifies a CSS selector that opens this context menu when a matching element is right-clicked.

string
Visible

Gets or sets whether the menu is visible.

Remarks

Setting this to opens the menu relative to its configured target. Use Double) to open the menu at a specific viewport position.

boolfalse

Events

Event Description Type
Closed

Occurs after the menu closes.

EventCallback<ContextMenuEventArgs>
Closing

Callback invoked before the menu closes. Set Cancel to prevent closing.

Func<ContextMenuClosingEventArgs, Task>
Opened

Occurs after the menu body has rendered and its initial position has been applied.

EventCallback<ContextMenuEventArgs>
Opening

Callback invoked before the menu opens. Set Cancel to prevent opening.

Func<ContextMenuOpeningEventArgs, Task>
VisibleChanged

Notifies when the effective menu visibility changes or a canceled request must be synchronized.

EventCallback<bool>

Methods

Method DescriptionReturnParameters
Hide Hides the context menu. Task
Reposition Repositions the visible context menu relative to its configured target.
Remarks

This method does nothing while the menu is hidden and does not invoke Opening, Opened, or VisibleChanged.

Task
Reposition Repositions the visible context menu at the supplied viewport coordinates.
Remarks

This method does nothing while the menu is hidden and does not invoke Opening, Opened, or VisibleChanged.

Taskdouble clientX, double clientY
Show Opens the context menu relative to its configured target.
Remarks

This method does nothing while the menu is visible. Use Reposition to update its position.

Task
Show Opens the context menu at the supplied viewport coordinates.
Remarks

This method does nothing while the menu is visible. Use Double) to update its position.

Taskdouble clientX, double clientY
On this page