Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-popover>

@methane-ui/ui~10.1 KB brotli (cold + Lit)~3.2 KB marginal

Floating overlay surface with dual-path CSS Anchor Positioning and JS collision fallback via adopted CSSStyleSheet.

When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-popover> (@methane-ui/ui)
Toggle Popover
Anchored Popover

Uses native Popover + CSS Anchor Positioning with automatic viewport fallback.

Ready · interact with <mth-popover>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/popover"></script>
<mth-popover placement="bottom" offset="8">Example</mth-popover>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
openopenbooleanfalseControls open visibility of the popover.
placementplacementstring"bottom"Preferred placement side and alignment relative to anchor.
offsetoffsetnumber8Pixel gap between anchor and popover surface.
modalmodalbooleanfalseEnables modal focus trapping and disables light-dismiss when true.
labellabelstring""Accessible label applied when modal dialog semantics are active.
closeOnEscapeclose-on-escapebooleantrueAllows dismissing the popover via the Escape key.
forceFallbackforce-fallbackbooleanfalseForces JS positioning and non-top-layer fallback mode.
anchor—Element | { getBoundingClientRect(): DOMRect } | DOMRect | nullnullOptional explicit Element, VirtualAnchor, or DOMRect positioning target.

Events

EventDetail TypeDescription
mth-openvoidCancelable event fired before opening the popover.
mth-after-openvoidFired after opening completes.
mth-close{ reason: string }Cancelable event fired before closing the popover.
mth-after-close{ reason: string }Fired after closing completes and focus restores.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
Escapebothopen and closeOnEscape is truedismisses popover and restores focus to trigger

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusFocus ownership matches focusModel="none".lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 1 APG keyboard transitions across LTR/RTL.mth-popover.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(open), :state(modal).Conformance suite
i18nRoutes 1 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test