DevExtreme v26.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

Angular Toast - Overview

The Toast is a UI component that displays pop-up notifications.

When you need to display a notification, call the notify(message, type, displayTime) method with values for the message, type, and displayTime properties passed as arguments.

DevExtreme Accessibility Compliance
DevExtreme component libraries meet a variety of WCAG and Section 508 compliance standards. To assess this demo's accessibility level, click the Run AXE® Validation button to launch the AXE® web accessibility evaluation tool.
All trademarks or registered trademarks are property of their respective owners. AXE® Terms of Use
The overall accessibility level of your application depends on the Toast features used.
Backend API
<div id="product-list"> <div class="header">Product List</div> <ul> @for(product of products; track product) { <li> <img [alt]="product.Name" [src]="product.ImageSrc" /> <div>{{ product.Name }}</div> <dx-check-box text="Available" (onValueChanged)="checkAvailable($event, product)" > </dx-check-box> </li> } </ul> <dx-toast [(visible)]="isVisible" [type]="type" [message]="message"> </dx-toast> </div>
import { bootstrapApplication } from '@angular/platform-browser'; import { Component, enableProdMode, provideZoneChangeDetection } from '@angular/core'; import { DxCheckBoxModule, DxToastModule } from 'devextreme-angular'; import { DxCheckBoxTypes } from 'devextreme-angular/ui/check-box'; import { Product, Service } from './app.service'; if (!/localhost/.test(document.location.host)) { enableProdMode(); } @Component({ selector: 'demo-app', providers: [Service], templateUrl: './app.component.html', styleUrls: ['./app.component.css'], imports: [ DxCheckBoxModule, DxToastModule, ], }) export class AppComponent { products: Product[]; isVisible = false; type = 'info'; message = ''; constructor(service: Service) { this.products = service.getProducts(); } checkAvailable({ value }: DxCheckBoxTypes.ValueChangedEvent, product: Product) { this.type = value ? 'success' : 'error'; this.message = product.Name + (value ? ' is available' : ' is not available'); this.isVisible = true; } } bootstrapApplication(AppComponent, { providers: [ provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }), ], });
::ng-deep .header { font-size: 34px; text-align: center; } ::ng-deep #product-list { padding: 10px; } ::ng-deep #product-list ul { text-align: center; list-style-type: none; margin: 20px 0; } ::ng-deep #product-list ul li { display: inline-block; width: 160px; margin: 10px; } ::ng-deep #product-list ul li img { width: 100px; } ::ng-deep .dx-toast-content { min-width: 300px; max-width: 400px; }
import { Injectable } from '@angular/core'; export class Product { ID: number; Name: string; Price: number; Current_Inventory: number; Backorder: number; Manufacturing: number; Category: string; ImageSrc: string; } const products: Product[] = [{ ID: 4, Name: 'SuperLED 50', Price: 1600, Current_Inventory: 77, Backorder: 0, Manufacturing: 55, Category: 'Televisions', ImageSrc: '../../../../images/products/4.png', }, { ID: 5, Name: 'SuperLED 42', Price: 1450, Current_Inventory: 445, Backorder: 0, Manufacturing: 0, Category: 'Televisions', ImageSrc: '../../../../images/products/5.png', }, { ID: 6, Name: 'SuperLCD 55', Price: 1350, Current_Inventory: 345, Backorder: 0, Manufacturing: 5, Category: 'Televisions', ImageSrc: '../../../../images/products/6.png', }, { ID: 7, Name: 'SuperLCD 42', Price: 1200, Current_Inventory: 210, Backorder: 0, Manufacturing: 20, Category: 'Televisions', ImageSrc: '../../../../images/products/7.png', }]; @Injectable() export class Service { getProducts(): Product[] { return products; } }
<!DOCTYPE html> <html lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" /> </head> <body class="dx-viewport"> <div class="demo-container"> <demo-app>Loading...</demo-app> </div> <script src="https://cdn.jsdelivr.net/npm/zone.js@0.16.2/bundles/zone.umd.js"></script> <script src="./bundle.js" type="module"></script> </body> </html>

You can specify one of the four predefined types of notifications, depending on the mood of the message:

  • 'info'
    A blue toast with a message bubble icon.

  • 'warning'
    A yellow toast with an exclamation mark icon.

  • 'error'
    A red toast with an X icon.

  • 'success'
    A green toast with a check mark icon.

In this demo, toggle check boxes to see the 'success' and 'error' notification types.

You can also customize the Toast appearance. Set the type property to 'custom' and use a contentTemplate. Refer to the following topic for more information: Customize the Content.

If you need to specify other Toast properties in addition to type and displayTime, call the notify(options, type, displayTime) method and pass an object as the argument. In this object, you can set any Toast property, such as shading, position, width, height, and others.