Context menu#
Component <neo-contextmenu> is a right-click menu built from the same <neo-menuitem> and <neo-submenu> rows as <neo-menu> . Mark the focusable element with data-neo-contextmenu-trigger; everything else inside becomes the menu panel. Opens via the keyboard context-menu key and
The selected state's markup and its scoped CSS. The CSS is wrapped in <style>@scope { ... }</style> and applies to the preview only. Edits change the preview above, applied live while Sync is on, or when you click Patch or Replace. Patch morphs the preview; Replace swaps it outright.
Signals
Datastar signals declared in the selected state's markup. Change a value to drive the preview, applied live while Sync is on, or when you click Patch.
Reference#
Attributes #
| Name | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Open state. Usually controlled by the host after a right-click or keyboard context-menu invocation. |
mode | "auto" | "cascade" | "push" | "auto" | Nested submenu strategy. Matches neo-menu: cascade on roomy pointers, push on narrow or touch-first contexts. |
screen-offset | CSS length | 8px | Minimum distance between the panel and viewport edge. |
clamp-placement | boolean | false | Allows the panel to re-anchor from the pointer when needed to remain visible. |
min-fit-height | CSS length | "content" | "content" | Strict-placement flip threshold inherited by submenus. |
min-fit-width | CSS length | "content" | "content" | Strict-placement flip threshold inherited by submenus. |
Slots #
| Name | Description |
|---|---|
[data-neo-contextmenu-trigger] | Required descendant (any depth, but not inside a nested <neo-menu> or <neo-contextmenu>) that receives the contextmenu and keyboard handlers. The first match wins. |
<neo-menu> | Exactly one required <neo-menu> child holding the rows. It supplies all menu behavior; the context menu only opens it at the pointer. Zero or multiple warn in the console. |
Events #
| Name | Detail | Bubbles | Description |
|---|---|---|---|
neo-contextmenu-open | none | yes | Fires when the menu opens. |
neo-contextmenu-close | none | yes | Fires when the menu closes. |
neo-menuitem-select | none | yes | Bubbles from selected child rows with { value }. |
Examples#
Simple#
A context menu wraps one trigger surface and a set of menu rows. The trigger stays in the page; the rows move into the generated floating panel.
Nested#
Context menus can be nested inside another trigger surface. Right-clicking the inner target opens its own menu without also opening the parent menu.
Custom content#
The trigger is regular light DOM and the panel uses the same menu CSS variables, so custom target surfaces, icon rows, widths, and danger treatments can be handled with a scoped stylesheet.