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.

    EXAMPLE
    TS
    HTML
    CSS

    Like this sample? Get access to our complete Ignite UI for Web Components toolkit and start building your own apps in minutes. Download it for free.

    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
    cmd
    import { defineComponents, IgcToastComponent } from 'igniteui-webcomponents';
    
    defineComponents(IgcToastComponent);
    ts

    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>
    html

    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>
    html

    EXAMPLE
    TS
    HTML
    ButtonOverviewStyle.css
    index.css

    Ignite UI for Web Components | CTA Banner

    Styling

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

    igc-toast {
      background-color: var(--ig-primary-500);
      color: var(--ig-primary-500-contrast);
    }
    css

    EXAMPLE
    TS
    HTML
    index.css
    ToastStyling.css

    API References

    Additional Resources