Skip to content

Context Menu

Displays pointer-contextual actions at the position of a browser context-menu event, normally a right-click.

Right-click here to open context menu
Root selections: 0

Interactive keyboard behavior

Right-click opening focuses the menu panel without highlighting an item. ArrowDown enters at the first enabled item and ArrowUp at the last; Home/End, typeahead, Enter/Space, and direction-aware submenu keys then use the same roving-focus controller as Dropdown Menu. Disabled items are skipped.

Set Loop="true" on each content panel that should wrap, set Direction="Direction.Rtl" on ContextMenu for RTL submenu keys, and provide TextValue for items whose visible markup does not expose a useful typeahead label.

ContextMenu is modal by default, containing focus, locking document scrolling, and consuming outside activation while the menu dismisses. Set Modal="false" when the rest of the page must stay interactive.

Checkboxes and radio groups expose CheckedChanged/ValueChanged. Cancel OnSelecting to keep the context menu open while still applying the selected state.

Set Disabled="true" on ContextMenuTrigger to keep ShardUI closed and preserve the browser's native context menu for that region. The trigger publishes data-state and data-disabled for state-aware styling.

Static SSR behavior

In true static SSR, right-clicking an enabled trigger prevents the native browser menu, positions the floating content at the pointer, focuses the first enabled item, and supports the shared Menu keyboard, typeahead, submenu grace-area, modal isolation, Escape, outside-click, and focus-return behavior without a Blazor circuit.

A selected leaf dispatches the bubbling, cancelable shardui:context-menu-select browser event. Its detail contains instanceId, itemId, textValue, itemType, checked, and value. Call event.preventDefault() to reject the selection and keep the menu open.

Blazor OnSelect callbacks are initial-response metadata in static SSR and do not execute in the browser. There is no touch long-press gesture or keyboard-open gesture, so keep important actions available through an explicit control such as DropdownMenu.

document.addEventListener("shardui:context-menu-select", event => {
  console.log(event.detail.itemId, event.detail.textValue);
});
An unhandled error has occurred. Reload 🗙

    Rejoining the server...

    Rejoin failed... trying again in seconds.

    Failed to rejoin.
    Please retry or reload the page.

    The session has been paused by the server.

    Failed to resume the session.
    Please reload the page.