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

<mth-dialog>

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

Top-layer modal and non-modal dialog wrapping native <dialog> with default, alert, confirm, and prompt variants.

When NOT to use: Do not use <mth-dialog> for non-modal contextual hints; use <mth-popover> or <mth-tooltip>.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-dialog> (@methane-ui/ui)
Open Live <mth-dialog>

Publish @methane-ui/ui release artifacts with Sigstore provenance?

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

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/dialog"></script>
<mth-dialog modal variant="default">Example</mth-dialog>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
openopenbooleanfalseControls open visibility of the dialog.
modalmodalbooleantrueOpens as modal top-layer dialog with backdrop and focus trap when true.
variantvariant'default' | 'alert' | 'confirm' | 'prompt'"default"Built-in semantic dialog preset (default | alert | confirm | prompt).
labellabelstring""Accessible dialog title rendered in header.
descriptiondescriptionstring""Optional descriptive copy for alert/confirm/prompt dialogs.
promptValueprompt-valuestring""Current input value when variant="prompt".
closeOnEscapeclose-on-escapebooleantrueAllows dismissing the dialog via the Escape key.

Events

EventDetail TypeDescription
mth-openvoidCancelable event fired before opening the dialog.
mth-after-openvoidFired once the entry transition settles.
mth-close{ reason: string }Cancelable event fired before closing the dialog.
mth-after-close{ reason: string }Fired once exit transition settles and focus restores.
mth-confirm{ variant: string; value?: string }Fired when the primary confirm/ok action button is clicked.
mth-cancel{ variant: string }Fired when the secondary cancel action button is clicked.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
Escapebothopen and closeOnEscape is truedismisses dialog and restores focus

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusFocus ownership matches focusModel="host".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-dialog.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(open), :state(modal).Conformance suite
i18nRoutes 5 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test