← All Components
<mth-toast>
Non-intrusive notification toast and runtime NotificationStore viewport with pause-on-hover/focus, LiveAnnouncer integration, and logical placement.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-toast>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/toast"></script>
<mth-toast variant="info" duration="5000">Example</mth-toast>import '@methane-ui/ui/toast';
import '@methane-ui/react';
export function Example() {
return <mth-toast variant="info" duration="5000">Example</mth-toast>;
}<script setup lang="ts">
import '@methane-ui/ui/toast';
</script>
<template>
<mth-toast variant="info" duration="5000">Example</mth-toast>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/toast';
import { MthToastDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthToastDirective],
template: `<mth-toast variant="info" duration="5000">Example</mth-toast>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/toast';
import MthToast from '@methane-ui/svelte/MthToast.svelte';
</script>
<MthToast variant="info" duration="5000">Example</MthToast>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
open | open | boolean | false | Controls standalone toast visibility. |
variant | variant | 'info' | 'success' | 'warning' | 'danger' | "info" | Semantic visual tone (info | success | warning | danger). |
duration | duration | number | 5000 | Auto-dismiss duration in milliseconds (0 disables auto-dismiss). |
closable | closable | boolean | true | Shows a dismiss button when true. |
placement | placement | 'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end' | "bottom-end" | Logical viewport corner or edge alignment. |
heading | heading | string | "" | Optional toast heading text. |
message | message | string | "" | Optional plain-text body overriding default slot fallback. |
forceFallback | force-fallback | boolean | false | Forces non-top-layer fallback mode. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-open | void | Cancelable event fired before showing the toast. |
mth-after-open | void | Fired once the entry animation completes. |
mth-close | { reason: string } | Cancelable event fired before dismissing the toast. |
mth-after-close | { reason: string } | Fired once the exit animation completes. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Escape | both | toast is focused and closable is true | dismisses toast notification |
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-toast.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(open), :state(paused). | Conformance suite |
| i18n | Routes 2 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |