← All Components
<mth-popover>
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
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>import '@methane-ui/ui/popover';
import '@methane-ui/react';
export function Example() {
return <mth-popover placement="bottom" offset="8">Example</mth-popover>;
}<script setup lang="ts">
import '@methane-ui/ui/popover';
</script>
<template>
<mth-popover placement="bottom" offset="8">Example</mth-popover>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/popover';
import { MthPopoverDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthPopoverDirective],
template: `<mth-popover placement="bottom" offset="8">Example</mth-popover>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/popover';
import MthPopover from '@methane-ui/svelte/MthPopover.svelte';
</script>
<MthPopover placement="bottom" offset="8">Example</MthPopover>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
open | open | boolean | false | Controls open visibility of the popover. |
placement | placement | string | "bottom" | Preferred placement side and alignment relative to anchor. |
offset | offset | number | 8 | Pixel gap between anchor and popover surface. |
modal | modal | boolean | false | Enables modal focus trapping and disables light-dismiss when true. |
label | label | string | "" | Accessible label applied when modal dialog semantics are active. |
closeOnEscape | close-on-escape | boolean | true | Allows dismissing the popover via the Escape key. |
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 popover. |
mth-after-open | void | Fired 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
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Escape | both | open and closeOnEscape is true | dismisses popover 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 1 APG keyboard transitions across LTR/RTL. | mth-popover.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(open), :state(modal). | Conformance suite |
| i18n | Routes 1 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |