Web Components Snackbar

    The Ignite UI for Web Components Snackbar component is used to provide feedback about an operation by showing a brief message at the bottom of the screen.

    Ignite UI for Web Components Snackbar Example

    This sample demonstrates how to create IgcSnackbarComponent component.

    Usage

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

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

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

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

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

    Examples

    Display Time

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

    Action Text

    By default, the snackbar component is hidden automatically after a period specified by the displayTime. You can use keepOpen property to change this behavior. In this way, the snackbar will remain visible. Using the snackbar actionText you can display an action button inside the component.

    Styling

    The snackbar component exposes several CSS parts (base, message, and action) to give you full control over its styling.

    igc-snackbar::part(base) {
        background: #0d6efd;
        border-color: #0d6efd;
        color: white;
    }
    

    API References

    Additional Resources