Web Components Toast Overview

    The Web Components Toast is a super lightweight and small pop-up component that is used for displaying a message content, notifying end-users about the status of a changed record. You can easily position and show Web Components toast notifications at the bottom or at any other specified area of the screen. Or you can also dismiss them in a simple and easy way.

    The Web Components Toast component is primarily used for system messaging, push notifications, warning messages, and information. It cannot be dismissed by the user. This control has different features like animation effects, display time property to configure how long the toast component is visible, styling, and others.

    Web Components Toast Example

    Take a look at the simple Ignite UI for Web Components Toast example below. The animated notification message pops up after clicking on the button.

    How To Use Ignite UI for Web Components Toast Notification

    First, you need to install the Ignite UI for Web Components by running the following command:

    npm install igniteui-webcomponents
    
    import { defineComponents, IgcToastComponent } from 'igniteui-webcomponents';
    
    defineComponents(IgcToastComponent);
    

    For a complete introduction to the Ignite UI for Web Components, read the Getting Started topic.

    The simplest way to display the toast component is to use its show method and call it on a button click.

    <igc-button onclick="toast.show()" variant="contained">Show Toast</igc-button>
    <igc-toast id="toast">Toast Message</igc-toast>
    

    Examples

    Properties

    Use the displayTime property to configure how long the toast component is visible. By default, it's set to 4000 milliseconds.

    By default, the toast component is hidden automatically after a period specified by the displayTime. You can use keepOpen property to change this behavior. In this way, the toast will remain visible.

    <igc-button onclick="toast.toggle()" variant="contained">Toggle Toast</igc-button>
    <igc-button onclick="toast.keepOpen = !toast.keepOpen" variant="contained">Toggle keepOpen property</igc-button>
    <igc-button onclick="toast.displayTime = 8000" variant="contained">Set DisplayTime to 8000</igc-button>
    
    <igc-toast id="toast">Toast Message</igc-toast>
    

    Styling

    You can style the Web Components IgcToastComponent notifications directly using its tag selector:

    igc-toast {
        background: #011627;
        color: #ECAA53;
        outline-color: #ECAA53;
    }
    

    API References

    Additional Resources