Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

ToastContainer

Show transient feedback messages from the Toast service.

Category
Feedback and status
Import
@neural-ui/core/toast
Selector
neu-toast-container
import { NeuToastContainerComponent } from '@neural-ui/core/toast';

Usage

Place one ToastContainer at application root and inject NeuToastService wherever a message is needed. show returns an id for dismiss(id); clear removes all messages and setPosition chooses the corner. duration is milliseconds; 0 keeps a message until dismissal. This documentation scopes the service per example to avoid affecting the site.

Examples

Try this application-owned interaction. Its event handling and initial data are included in Code.

Examples

Messages: 0

Try and configure

Change the public options, try the result and inspect the updated template. Code contains the complete executable implementation.

Try and configure

Messages: 0

template.html
<div class="remaining-actions">
  <button neu-button (neuClick)="show()">
    {{ t("Add message", "Aรฑadir mensaje") }}</button
  ><button neu-button variant="outline" (neuClick)="service.clear()">
    {{ t("Clear all", "Limpiar todo") }}
  </button>
</div>
<neu-toast-container />
toast.ts
this.service.setPosition("top-right");
this.service.show({
  "tone": "success",
  "message": "Changes saved",
  "title": "Workspace",
  "duration": 0
});

State and events

Place one ToastContainer at application root and inject NeuToastService wherever a message is needed. show returns an id for dismiss(id); clear removes all messages and setPosition chooses the corner. duration is milliseconds; 0 keeps a message until dismissal. This documentation scopes the service per example to avoid affecting the site.

Accessibility and keyboard

Messages announce status or alerts according to tone. Tab reaches the dismiss button; feedback does not steal focus.

Key
Action
Tab Reach available dismiss buttons without the notification stealing focus.
Enter Dismiss the notification from its focused close button.
Space Dismiss the notification from its focused close button.

API

Inputs, models and Outputs are extracted from the installed Core package. Named public types link to their definitions. Templates below include executable examples.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

This component does not expose content projection or public customization templates.

Public configuration

Name
Contract
NeuToastServiceexport declare class NeuToastService { clear(): void; dismiss(id: string): void; error(message: string, opts?: Partial<NeuToastOptions>): string; info(message: string, opts?: Partial<NeuToastOptions>): string; setPosition(position: NeuToastPosition): void; show(options: NeuToastOptions): string; success(message: string, opts?: Partial<NeuToastOptions>): string; warning(message: string, opts?: Partial<NeuToastOptions>): string; readonly position: import("@angular/core").WritableSignal<NeuToastPosition>; readonly toasts: import("@angular/core").WritableSignal<NeuToastItem[]>; }

Public Types

Open a type to inspect its definition and interface fields.

Styles and tokens

Use the supported public tokens listed below. Surrounding layout belongs to your application; validate the result in light and dark modes and narrow containers.

Specific tokens

This component uses shared theme tokens rather than dedicated component hooks.

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
No data