ContextMenu
Right-click menu, or a controlled menu for virtualized or delegated targets. Wrap a region in it and the menu opens at the pointer on right-click (Control-click stays native); or drive it yourself with open and a viewport position. Arrow keys, Home, End and Escape work as in a native menu, and focus returns to where it was.
Leave it out for a controlled menu.
ContextMenuItemCheckbox, ContextMenuSeparator, ContextMenuLabel).
controlled menu; by default the right-click point.
follow.
| Type | Name | Description |
|---|---|---|
| import(‘svelte’).Snippet | children? |
The region that answers a right-click. |
| import(‘svelte’).Snippet | content? |
The menu items (ContextMenuItem, |
| boolean | open? |
Whether the menu is open. Bindable. |
| { x: number, y: number | | |
null} [position] – Viewport coordinates for a |
| string | label? |
Accessible name of the menu. Defaults to “Actions”. |
| () => void | onclose? |
Called when the menu closes, so a controlled target can |
| string | class? |
Extra classes on the trigger region. |
<ContextMenu>
<div>Right-click here</div>
{#snippet content()}
<ContextMenuItem onclick={rename}>Rename</ContextMenuItem>
{/snippet}
</ContextMenu>