Context Menu

A menu that opens at the pointer on right-click, or on long-press on touch screens.

Installation

bash
shellui-native add context-menu

Platforms: MAUI · Avalonia. Also installs icon, element-extensions.

Usage

Basic

Rendered with ShellUI for Blazor
Right-click here
<ui:ContextMenu>
    <ui:ContextMenuTrigger>
        <Border StrokeDashArray="4,4" HeightRequest="120">
            <Label Text="Right-click here" HorizontalOptions="Center" VerticalOptions="Center" />
        </Border>
    </ui:ContextMenuTrigger>
    <ui:ContextMenuContent>
        <ui:ContextMenuItem Text="Back" Icon="ArrowLeft" Shortcut="Alt+Left" />
        <ui:ContextMenuItem Text="Reload" Icon="RefreshCw" Shortcut="Ctrl+R" />
        <ui:ContextMenuItem Text="Copy link" Icon="Link" />
        <ui:ContextMenuSeparator />
        <ui:ContextMenuItem Text="Delete" Icon="Trash2" IsDestructive="True" />
    </ui:ContextMenuContent>
</ui:ContextMenu>
Avalonia, running in your browser

MAUI and Avalonia

  • MAUI opens the menu on right-click, or on a long press on touch screens.
  • Avalonia also opens it with the Menu key or Shift+F10 while focus is inside the trigger, and a right-click while it's open moves it.
  • On Avalonia the items are tab stops.

API

ContextMenu

XAML children go to Items on Avalonia.

Property Type Default Description
IsOpen bool false Whether it's open. Two-way bindable.
Event Arguments Description
IsOpenChanged bool Opened or closed.
Method Description
OpenAt(Point? point) Opens the menu at a point relative to this view, or below the trigger when null.
SetOpen(bool value) Opens or closes it.
Toggle() Opens it if closed, closes it if open.
Close() Closes it.

ContextMenuTrigger

No properties of its own.

ContextMenuContent

XAML children go to Items on Avalonia and Children on MAUI.

No properties of its own.

ContextMenuItem

Property Type Default Description
Text string — Text shown by the component.
Icon IconName None Lucide icon from IconName; None for no icon.
Shortcut string — Keyboard hint shown at the end of the row (display only).
IsDestructive bool false Draws the item in the destructive colour.
Event Arguments Description
Clicked — Clicked or tapped (or Enter / Space with keyboard focus).
Method Description
Press() Picks the item in code, as a click or Enter/Space would. Avalonia only.

ContextMenuSeparator

No properties of its own.

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 retry or reload the page.