<re-toast>
A custom-element wrapper that hosts a toast region in light DOM. Its
.show(message, options) method matches the showToast() API and returns the
same controller. See the custom elements overview
for how the <re-*> tags work.
Import once to register the tag, then call .show(...):
import "@relements/core/elements/re-toast";
const toaster = document.querySelector("re-toast");toaster.show("Saved.");toaster.show("Upload complete.", { tone: "success" });toaster.show("Network error.", { tone: "danger", duration: 8000 });Trigger toasts
Section titled “Trigger toasts”The buttons below call toaster.show(...) on the <re-toast> element:
<div class="row">
<button
type="button"
class="re-button"
id="rt-default"
data-demo-toast="Saved."
data-demo-toast-target="toaster"
>
Default
</button>
<button
type="button"
class="re-button"
data-variant="secondary"
id="rt-success"
data-demo-toast="Upload complete."
data-demo-toast-tone="success"
data-demo-toast-target="toaster"
>
Success
</button>
<button
type="button"
class="re-button"
data-variant="danger"
id="rt-danger"
data-demo-toast="Network error."
data-demo-toast-tone="danger"
data-demo-toast-target="toaster"
>
Danger
</button>
</div>
<re-toast id="toaster"></re-toast> Accessibility
Section titled “Accessibility”- Keyboard — Toasts never steal focus, so there is no trap and nothing to
return to. Each toast carries a native dismiss
<button>reachable withTaband activated withEnter/Space. - Focus — The dismiss button shows a visible
:focus-visiblering (--re-shadow-focus). - Semantics — On connection
<re-toast>becomes therole="region"live region, labelledaria-label="Notifications"(override by settingaria-labelon the element). Its inner list isaria-live="polite"witharia-relevant="additions", so screen readers announce each new toast as it is appended; setdata-live="assertive"on the element to interrupt instead. Individual toasts arerole="status", except thedangertone, which isrole="alert". The dismiss button is labelledaria-label="Dismiss notification". - Notes — Tone is conveyed by both the live-region role and tinted
surface/border (not colour alone), and
--re-shadow-focusplus the tone borders keep the toast operable under forced-colors / High Contrast Mode. See the accessibility guide for the system-wide stance. The same region and roles back the functionalshowToast()API.