Toast
vig-toaster
import { Toaster, Toast } from '@vigdx/ui/toast';Variants
<vig-toaster /> once in the app shell (see the app.ts tab; this site already does). Then inject the Toast service anywhere and call success() , info() , warning() or error() with a message and an optional title.
Duration
show() takes all options. duration is in milliseconds (default 5000); 0 keeps the toast until it is dismissed. Hovering a toast pauses its timer, and clear() removes every toast.
Dismiss from code
show() and the shortcuts return the toast's id; pass it to dismiss() , e.g. to replace a progress toast with the result. closable: false hides the close button.
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="toaster"][data-part="region"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="toaster"]
| Part | Element | data-state |
|---|---|---|
region | — | |
toast | vig-message . | — |
| Attribute | Meaning |
|---|---|
data-toast-id | Toast.show() returned, unique while it is shown. |
Accessibility
- Toasts live in a
role="region"landmark named byariaLabel(localized “Notifications” by default), so users can find them again. - Each toast is announced by the toaster itself, title and message together:
errorandwarningassertively and after their severity (“Error: …”, translatable witherrorLabelandwarningLabel), the other variants politely. It usesariaNotify()where the browser has it, otherwise its own live log, which is in the page from the start and only ever gains entries, so toasts arriving together are all read (a message inserted together with its live role is not announced reliably). A toast queued behind a modal dialog is announced once the dialog closes. - Toasts never take focus. Hovering or keyboard focus inside a toast pauses its timer; for messages users need time to read or act on, use
duration: 0or keep the information in the page. - Dismissing the focused toast moves focus to the next toast, or back to where it was before entering the notifications.
- While a modal dialog or drawer is open the page behind it is inert, so toasts raised then wait and every timer stands still; they appear once the last modal closes.
- Close buttons are named by
closeAriaLabelon the toaster (localized “Dismiss” by default).
API
Toaster
vig-toasterHost for the Toast service — place once in the app shell. Each toast
renders as a vig-message on an opaque card. A message inserted together
with its live role is not announced reliably, so the toaster announces
each new toast itself, errors and warnings assertively and after their
severity (errorLabel, warningLabel: "Error: …"), the rest politely:
through ariaNotify() where supported, otherwise by adding an entry to its
own live log, which is in the page from the start. Entries are added, never
replaced, so toasts that arrive together are all read, and the log is
apart from the shared announcer that form errors use.
Hover and keyboard focus pause a toast; dismissing the focused toast moves
focus to the next one, or back to where it was before entering the
region. A stack taller than the viewport scrolls, and the region then
joins the tab order so keyboard users can scroll it.
Each toast card carries data-toast-id, unique while it is shown.
data-toast-id
| Name | Type | Default | Description |
|---|---|---|---|
ariaLabel | string | undefined | undefined | — |
closeAriaLabel | string | undefined | undefined | — |
errorLabel | string | undefined | undefined | Spoken before error toasts (i18n); defaults to |
position | ToasterPosition | 'top-right' | Where the stack sits. The default is the physical top right corner (as
in 2.0, until 3.0); prefer |
warningLabel | string | undefined | undefined | Spoken before warning toasts (i18n); defaults to |
Toast
Imperative notifications (PrimeNG MessageService territory): place
once in the app shell, then toast.success('Saved').
Hovering or focusing a toast pauses its timer; leaving restarts the full
delay.
While a modal vig-dialog / vig-drawer is open the page behind it is inert, so a toast there could be neither read nor dismissed: new toasts queue up and every timer stands still until the last modal closes.
| Signature | Description |
|---|---|
clear(): void | — |
dismiss(id: number): void | — |
error(message: string, title?: string): number | — |
info(message: string, title?: string): number | — |
pause(id: number): void | Stops the auto-dismiss timer (used while hovered or focused). |
resume(id: number): void | Restarts the full auto-dismiss delay (deferred while a modal is open). |
show(options: ToastOptions): number | — |
success(message: string, title?: string): number | — |
warning(message: string, title?: string): number | — |