Toast
Toast notifications for transient feedback, with semantic variants, descriptions, action buttons, promise integration, and persistent toasts.
import { Toaster, toast } from "@plexui/vue/components/Toast";Render <Toaster /> once near the root of your app, then call toast(...) from any handler. PlexUI renders toasts and manages their interaction while vue-sonner supplies the toast store. It retains vue-sonner’s toast API (toast.promise, toast.loading, toast.dismiss, toast.custom). The examples call toast from the template; in an app, import it in <script setup>.
Examples
Overview
Variants
Description
Action
Promise
Long content
Compact
Persistent
API
Toaster
| Prop | Type | Default | Description |
|---|---|---|---|
position | "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | "top-center" | Where toasts anchor on the viewport |
duration | number | 3000 | Default auto-dismiss duration in ms |
offset | string | number | { top?; right?; bottom?; left? } | 32px | Distance from the viewport edge. Without a top or bottom edge here, the page's --toast-offset-top or --toast-offset-bottom sets it. |
mobile-offset | string | number | { top?; right?; bottom?; left? } | 16px top and bottom, 14px at the sides, past the safe area | Gutter under 600px, where a toast fills the width between the side gutters. Explicit edges override their defaults; omitted edges keep them, and the page's --toast-mobile-offset-top or --toast-mobile-offset-bottom sets the top or bottom one. |
gap | number | — | Gap between stacked toasts in px |
PlexUI implements the compatible vue-sonner Toaster options (expand, visible-toasts, hotkey, dir, swipe-directions, etc.) in its renderer. theme, rich-colors, toast-options, style and close-button are left out of ToasterProps, because Plex sets them for its tokens, icons and theme sync. The success-icon, error-icon, warning-icon, info-icon, loading-icon and close-icon slots replace the default icons.
toast
vue-sonner's toast, wrapped so a per-toast descriptionClass reaches the description as in React. The full surface (toast(), .success, .error, .warning, .info, .message, .loading, .promise, .dismiss, .custom) is available with full TypeScript inference. vue-sonner spells a few options the Vue way: class (sonner's className), classes (classNames) and descriptionClass (descriptionClassName), and toast.custom takes a component.
PlexUI renders and manages toast interaction in both frameworks while retaining vue-sonner as the Vue toast store. Timers, swipe cancellation, focus restoration and hidden-toast accessibility follow the same behavior. Vue-specific option names and custom components follow vue-sonner’s API.
Types
Action, ExternalToast, and ToastT are re-exported so you can type helpers without importing from vue-sonner directly.
Screen readers
The toast region is not a live region itself, so a toast is never read twice. A hidden polite announcer reads each toast once, its title and then its description, and again only when its words change, as a promise that settles or a custom toast that updates itself. An error that waits to be closed, toast.error(...) with duration: Infinity (its own or the Toaster's), is role="alert" instead: read at once, and only by its role. One that turns up behind the stack, where its role cannot speak, is read by a hidden assertive announcer instead.
Over a modal Dialog
The region stays a layer of its own above a modal Dialog. The Dialog hides the rest of the page from a screen reader, but not the region, so its toasts are still read. Focus can move into a toast (Alt+T, or a press on its button) without the Dialog's focus trap pulling it back, Escape there returns focus to the Dialog without closing it, and a press on a toast's close or action button is not a press outside: the Dialog stays open. While a modal layer is open, the region keeps its presses and focus from the document listeners added after the Toaster mounted, so render <Toaster /> once at the root, as above. A Toaster mounted later still keeps a PlexUI Dialog open on a press, but the Dialog's focus trap can then pull focus back.
Theme sync
<Toaster /> reads data-theme on <html> on mount and observes changes via MutationObserver. Toggling light and dark rethemes toasts that are already on screen, with no extra theme dependency.
Styling
Toast reads the shared semantic color, typography and spacing tokens listed in Design tokens, so it follows theme changes made there. The close button (closeButton on a toast) draws a 20px face in the text color with the ring of an outline Button, visible in both themes, inside a 26px target; on a touch screen its target is 44px. These variables move the toaster per page, set on :root or any ancestor of the Toaster (a page with its own top bar, say):
--toast-offset-top,--toast-offset-bottom: distance from the top and bottom of the window above 600px (default32px)--toast-mobile-offset-top,--toast-mobile-offset-bottom: the same under 600px (default16pxpast the safe area)--z-toast: stack order of the toaster (default100000)