@methane-ui/ui~12.3 KB brotli (cold + Lit)~4.4 KB marginalAnchored dropdown menu coordinating <mth-menu-item> children via roving focus, typeahead, dual-path positioning, and top-layer popover overlay.
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 | Controls open visibility of the dropdown menu. |
placement | placement | string | "bottom-start" | Preferred placement relative to trigger. |
offset | offset | number | 6 | Pixel distance between trigger and menu surface. |
label | label | string | "" | Accessible label for the menu container. |
closeOnSelect | close-on-select | boolean | true | Closes the menu automatically after selecting a normal/radio item. |
roleMode | role-mode | 'menu' | 'listbox' | "menu" | Switches internal container semantics between menu (default) and listbox. |
forceFallback | force-fallback | boolean | false | Forces JS positioning and non-top-layer fallback mode. |
anchor | — | Element | { getBoundingClientRect(): DOMRect } | DOMRect | null | null | Optional explicit Element, VirtualAnchor, or DOMRect positioning target. |
Events
| Event | Detail Type | Description |
|---|
mth-open | void | Cancelable event fired before opening the menu. |
mth-after-open | void | Fired after opening completes. |
mth-close | { reason: string } | Cancelable event fired before closing the menu. |
mth-after-close | { reason: string } | Fired after closing completes and focus restores. |
mth-select | { value: string; checked: boolean } | Fired when a menu item is activated with { value, checked }. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|
| ArrowDown | both | open | moves active menu item down (wrapping at end) |
| ArrowUp | both | open | moves active menu item up (wrapping at start) |
| Home | both | open | focuses first enabled menu item |
| End | both | open | focuses last enabled menu item |
| Enter | both | open and active item exists | selects active item and emits mth-select |
| Escape | both | open | closes menu and restores focus to trigger |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="none". | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 6 APG keyboard transitions across LTR/RTL. | mth-dropdown-menu.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(open). | Conformance suite |
| i18n | Routes 1 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |