Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
<app-toaster> └── generated <toast-toaster> └── notification created with toast ├── status icon (optional) ├── title (optional) ├── description (optional) ├── cancel action (optional) ├── primary action (optional) └── close trigger
Examples
Action And Cancel
Loading...
Default
Loading...
Loading
Loading...
Types
Loading...
API Reference
<app-toaster>
Mount this component once near the application root. It renders notifications from the exported
toast store at bottom-end with overlapping enabled and a 16-pixel gap. The component has no
inputs or outputs.
toast
The preconfigured CreateToasterReturn used to create and control notifications.
| Method | Returns | Description |
|---|---|---|
create(options) | string | Creates a toast and returns its ID. |
update(id, options) | string | Updates an existing toast and returns its ID. |
dismiss(id?) | void | Starts dismissing one toast or all toasts. |
remove(id?) | void | Immediately removes one toast or all toasts. |
success(options) | void | Creates a success toast. |
error(options) | void | Creates an error toast. |
info(options) | void | Creates an informational toast. |
warning(options) | void | Creates a warning toast. |
loading(options) | void | Creates a loading toast. |
promise(promise, options) | Controller or undefined | Tracks a promise with loading, success, and error states. |
pause(id?) / resume(id?) | void | Pauses or resumes dismissal timers. |
isVisible(id) | boolean | Returns whether a toast is visible. |
isDismissed(id) | boolean | Returns whether a toast has been dismissed. |
getVisibleToasts() | Partial<ToastMachineProps>[] | Returns the visible toast records. |
getCount() | number | Returns the number of stored toasts. |
expand() / collapse() | void | Expands or collapses an overlapping toast stack. |
Toast Options
| Option | Type | Description |
|---|---|---|
id | string | undefined | Custom toast identifier. |
title | any | Toast title content. |
description | any | Toast description content. |
type | ToastType | undefined | Visual type such as success, error, or loading. |
duration | number | undefined | Time in milliseconds before dismissal. |
removeDelay | number | undefined | Delay before a dismissed toast is unmounted. |
priority | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Queue priority. |
closable | boolean | undefined | Whether the toast can be closed by the user. |
action | ToastActionOptions | undefined | Primary action label and callback. |
meta | Record<string, any> | undefined | Application data consumed by a custom item template. |
onStatusChange | ((details: ToastStatusChangeDetails) => void) | undefined | Runs when lifecycle status changes. |
The bundled template also recognizes meta.cancelAction with a label and onClick callback.
Context and Utilities
| Export | Angular API |
|---|---|
createToaster(props?) | Creates an independent signal-compatible toast store. |
ToastContext | Structural directive [toast-context] exposing a toast API to a template. |
useToast(options) | Creates the signal-backed toast machine inside an injection context. |
useToastGroup(options) | Creates the signal-backed toast-group machine. |
injectToastContext() | Injects the nearest toast root. |
injectToastContextCarrier() | Injects the carrier used to preserve toast context. |
ToastImports | Readonly collection containing AppToasterComponent for importing. |
AppToasterComponent is also exported as ToasterComponent.
Types
| Export | Description |
|---|---|
ToastType | Visual toast type, including success, error, and loading. |
ToastStatus | Lifecycle status: visible, dismissing, or unmounted. |
ToastStatusChangeDetails | Details passed to onStatusChange. |
ToastOptions | Options accepted when creating a toast. |
ToastPromiseOptions | Loading, success, error, and finalization options for a promise. |
ToastStoreProps | Placement, timing, spacing, overlap, and queue configuration. |
ToastStore | Imperative store API used by toast. |
CreateToasterProps | Angular alias for toast-store configuration. |
CreateToasterReturn<T> | Store returned by createToaster. |
UseToastOptions | Options accepted by useToast. |
UseToastReturn | Signal-backed toast machine returned by useToast. |
UseToastGroupOptions | Options accepted by useToastGroup. |
UseToastGroupReturn | Signal-backed toast-group machine returned by useToastGroup. |
Angular
React
Solid
Svelte
Vue