@methane-ui/ui~9.0 KB brotli (cold + Lit)~2.6 KB marginalRight-click and programmatic virtual-anchor context menu with nested submenus and OverlayController top-layer fallback.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Multi-Framework Playground & Snippets
Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|
open | open | boolean | false | Whether the context menu popup is open. |
label | label | string | "" | Accessible label for the context menu. |
forceFallback | force-fallback | boolean | false | Forces non-top-layer fallback overlay and JS positioning. |
items | — | ReadonlyArray<unknown> | [] | Structured menu tree supporting separators, shortcuts, and nested submenus. |
Events
| Event | Detail Type | Description |
|---|
mth-select | { value: string; label: string } | Fired when a leaf menu item is activated. |
mth-open | void | Cancelable event fired before opening the menu. |
mth-after-open | void | Fired after the menu opens. |
mth-close | { reason: string } | Cancelable event fired before closing the menu. |
mth-after-close | { reason: string } | Fired after the menu closes. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|
| ArrowDown | both | open | moves focus to next enabled menu item |
| ArrowUp | both | open | moves focus to previous enabled menu item |
| ArrowRight | both | focused on item with submenu | opens nested submenu |
| ArrowLeft | both | inside nested submenu | closes nested submenu |
| Escape | both | open | closes context menu and restores focus |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 5 APG keyboard transitions across LTR/RTL. | mth-context-menu.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(open). | Conformance suite |
| i18n | Routes 2 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |