Search documentation

Search the documentation and open a page.

Displays a brief, temporary notification about an action or event.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/toast

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.

MethodReturnsDescription
create(options)stringCreates a toast and returns its ID.
update(id, options)stringUpdates an existing toast and returns its ID.
dismiss(id?)voidStarts dismissing one toast or all toasts.
remove(id?)voidImmediately removes one toast or all toasts.
success(options)voidCreates a success toast.
error(options)voidCreates an error toast.
info(options)voidCreates an informational toast.
warning(options)voidCreates a warning toast.
loading(options)voidCreates a loading toast.
promise(promise, options)Controller or undefinedTracks a promise with loading, success, and error states.
pause(id?) / resume(id?)voidPauses or resumes dismissal timers.
isVisible(id)booleanReturns whether a toast is visible.
isDismissed(id)booleanReturns whether a toast has been dismissed.
getVisibleToasts()Partial<ToastMachineProps>[]Returns the visible toast records.
getCount()numberReturns the number of stored toasts.
expand() / collapse()voidExpands or collapses an overlapping toast stack.

Toast Options

OptionTypeDescription
idstring | undefinedCustom toast identifier.
titleanyToast title content.
descriptionanyToast description content.
typeToastType | undefinedVisual type such as success, error, or loading.
durationnumber | undefinedTime in milliseconds before dismissal.
removeDelaynumber | undefinedDelay before a dismissed toast is unmounted.
priority1 | 2 | 3 | 4 | 5 | 6 | 7 | 8Queue priority.
closableboolean | undefinedWhether the toast can be closed by the user.
actionToastActionOptions | undefinedPrimary action label and callback.
metaRecord<string, any> | undefinedApplication data consumed by a custom item template.
onStatusChange((details: ToastStatusChangeDetails) => void) | undefinedRuns when lifecycle status changes.

The bundled template also recognizes meta.cancelAction with a label and onClick callback.

Context and Utilities

ExportAngular API
createToaster(props?)Creates an independent signal-compatible toast store.
ToastContextStructural 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.
ToastImportsReadonly collection containing AppToasterComponent for importing.

AppToasterComponent is also exported as ToasterComponent.

Types

ExportDescription
ToastTypeVisual toast type, including success, error, and loading.
ToastStatusLifecycle status: visible, dismissing, or unmounted.
ToastStatusChangeDetailsDetails passed to onStatusChange.
ToastOptionsOptions accepted when creating a toast.
ToastPromiseOptionsLoading, success, error, and finalization options for a promise.
ToastStorePropsPlacement, timing, spacing, overlap, and queue configuration.
ToastStoreImperative store API used by toast.
CreateToasterPropsAngular alias for toast-store configuration.
CreateToasterReturn<T>Store returned by createToaster.
UseToastOptionsOptions accepted by useToast.
UseToastReturnSignal-backed toast machine returned by useToast.
UseToastGroupOptionsOptions accepted by useToastGroup.
UseToastGroupReturnSignal-backed toast-group machine returned by useToastGroup.