Menu
Description
A menu surface composed of clickable items, optional headers, dividers and arbitrarily deep nested submenus. Built on top of the Popover primitive, so positioning, click-outside dismissal and animation are inherited from the shared popover machinery.
Usage
API reference
public sealed class MenuA menu surface composed of clickable items, optional headers, dividers and arbitrarily deep nested submenus. Built on top of the Popover primitive, so positioning, click-outside dismissal and animation are inherited from the shared popover machinery.
Remarks
Menu is the recommended primitive for application menus, dropdown menus and action menus shown in response to a button click or other explicit user gesture. For the classic right-click context menu (which uses precise mouse-tracking to keep submenus open while the cursor traces toward them) use the existing ContextMenu component. Unlike the legacy ContextMenu, Menu imposes no artificial limit on submenu depth — a menu item's submenu may itself contain items with submenus, and so on. var fileMenu = UI.Menu() .Items( UI.MenuHeader("File"), UI.MenuItem("New", UIcons.Plus).OnClick(() => New()), UI.MenuItem("Open…", UIcons.FolderOpen).OnClick(() => Open()), UI.MenuDivider(), UI.MenuItem("Export").SubMenu( UI.Menu().Items( UI.MenuItem("PDF").OnClick(() => ExportPdf()), UI.MenuItem("CSV").OnClick(() => ExportCsv())))); var trigger = UI.Button("File").OnClick(b => fileMenu.ShowFor(b));
- Namespace
- Tesserae
Constructors
| Name | Description |
|---|---|
| Menu | Creates a new, empty menu. |
Properties
| Name | Description |
|---|---|
| IsVisible | Gets a value indicating whether the menu is currently displayed. |
Methods
| Name | Description |
|---|---|
| Add | Adds a single item to this menu. Most code prefers the params overload Items together with the UI.MenuItem(...) / UI.MenuHeader(...) factory helpers. |
| Items | Adds the given items to this menu, in order. |
| Placement | Sets the preferred placement of this menu relative to its anchor. Defaults to BottomStart, which mirrors the standard dropdown-menu placement of platforms like Windows and macOS. |
| OnHidden | Registers a callback that fires after this menu has been hidden. |
| ShowFor | Shows the menu anchored to the rendered element of anchor. |
| Hide | Hides the menu (and any of its open submenus) if currently visible. |
public Menu Add(Item item)Adds a single item to this menu. Most code prefers the params overload Items together with the UI.MenuItem(...) / UI.MenuHeader(...) factory helpers.
public Menu Placement(TooltipPlacement placement)Sets the preferred placement of this menu relative to its anchor. Defaults to BottomStart, which mirrors the standard dropdown-menu placement of platforms like Windows and macOS.
public Menu OnHidden(Action onHidden)Registers a callback that fires after this menu has been hidden.
| Overload | |
|---|---|
| ShowFor(IComponent) | Shows the menu anchored to the rendered element of anchor. |
| ShowFor(HTMLElement) | Shows the menu anchored to the given DOM element. |