Skip to main content
Version: Next

Toast

Notification patterns and full API reference for @editora/toast in the Editora ecosystem.

AI Guides​

Installation​

npm i @editora/toast
import "@editora/toast/toast.css";
import toast from "@editora/toast";

Quick Start​

import { toast } from "@editora/toast";
import "@editora/toast/toast.css";

toast.success("Document saved");
toast("Copied to clipboard"); // a plain toast: no level, no icon

toast.promise(saveDocument(), {
loading: "Saving...",
success: (file) => `Saved ${file.name}`,
error: "Could not save",
});

toast is the whole simple API: toast(message), the level methods, and show, promise, update, dismiss (with no id it clears every toast), clear and configure. It needs no provider and does nothing on the server.

Usage Patterns​

  • Simple API (toast) for notifications, promises and updates.
  • Advanced API (toastAdvanced) for grouped toasts, plugins, subscriptions and state inspection.
  • Use theme + position defaults globally with toast.configure(...).
import { toastAdvanced } from "@editora/toast";

toastAdvanced.configure({
position: "top-right",
theme: "system", // follows the OS, or the app's .dark / data-theme switch on <html>
maxVisible: 4,
});

const id = toastAdvanced.loading("Export started");
setTimeout(() => toastAdvanced.update(id.id, { message: "Export complete", level: "success" }), 1200);

Stacking​

Several toasts fold into a deck by default: the newest in full, the older ones as edges behind it. Hovering or focusing the deck opens it into a list, and the timers of its toasts wait while it is open (the time that was left is kept). The newest toast is always nearest the edge of the screen. configure({ stack: false }) keeps a plain list.

Icons and themes​

Each level has an icon of its own shape (success, error, warning, info, a spinner for loading). icon takes text, an emoji or a DOM node, or false for none; configure({ icons: false }) removes the built-in icons. The card is opaque and neutral; richColors: true tints it with the level's colour. A theme is a set of CSS variables (--et-bg, --et-text, --et-success, ...), so a custom theme is a few lines of CSS.

Keyboard​

Every toast is a Tab stop. Alt+T (hotkey) moves focus to the newest toast and opens the stack, Escape dismisses the focused toast and moves on to the next one (or back to where you were), and the timers wait while a toast has keyboard focus (pauseOnFocus). configure({ hotkey: false }) turns the shortcut off.

API Reference​

SurfaceTypeNotes
toast (named and default export)Function + methodstoast(message, options?) for a plain toast, plus the level methods and show, promise, update, dismiss(id?), clear, configure
toast.info/success/error/warning/loading(message, optionsOrDuration?, theme?, position?)MethodsLevel methods; they normalize to modern options
ToastManagerClass exportCore engine for lifecycle, queue, grouping, plugins
toastAdvancedAdvanced API objectFull-featured runtime API
toastProAliasRe-export alias of toastAdvanced
toastAdvanced.show(options)MethodCreate toast with full options
toastAdvanced.update(id, partialOptions)MethodPatch existing toast state
toastAdvanced.dismiss(id) / clear()MethodsRemove one/all toasts
toastAdvanced.promise(promise, options)MethodPromise lifecycle notifications
toastAdvanced.group(groupId, options)MethodGrouped toast streams
toastAdvanced.configure(config)MethodRuntime config merge
toastAdvanced.use(plugin)MethodPlugin registration
toastAdvanced.getToasts/getGroups/getConfigMethodsState inspection
toastAdvanced.onEditorEvent/triggerEditorEventMethodsEditor-event bridge hooks
toastAdvanced.destroy()MethodFull manager teardown
ToastOptionsLegacyTypeBackward-compatible options contract
ToastLevelAdvanced, ToastPosition, ToastThemeTypesCore enums/unions
ToastAction, ToastProgress, ToastContentTypesContent/action contracts
ToastOptionsAdvanced, ToastInstance, ToastConfigTypesRuntime data contracts
ToastPlugin, ToastPromiseOptionsTypesPlugin and promise integration
Animation types (SpringConfig, AnimationType, AnimationConfig, SpringAnimation, BounceAnimation, SlideAnimation, ZoomAnimation, FlipAnimation, FadeAnimation, ElasticAnimation, RotateAnimation, CustomAnimation)TypesAnimation system contracts
Package export @editora/toast/toast.cssCSS entryToast theme and component styling

Best Practices​

  • Keep messages short and action-oriented.
  • Use levels consistently (success for completion, warning for recoverable issues, error for blocking failures).
  • Cap concurrent toasts with config to prevent notification overload.

Accessibility​

  • Every toast and its buttons are keyboard reachable (Tab, Alt+T, Escape); see Keyboard above.
  • Status icons have a different shape per level and are hidden from screen readers; the message text must still explain the status.
  • Errors are announced as alerts, other levels politely; prefers-reduced-motion turns the slide into a fade.
  • Use polite timing and avoid high-frequency toast spam for autosave events.

Performance Notes​

  • Reuse one manager instance through exported API.
  • Batch repeated low-priority notifications.
  • Use grouped toasts for recurring task streams (import/export sync) instead of creating independent stacks.