Snackbar

A Snackbar (also called Toast) is an Alert that pops up dynamically to notify the user about an important message.

Note

The Snackbar is dependant on ISnackbar service and MudSnackbarProvider.

Check the Installation page for instructions regarding default setup.

Usage

This is the simplest way of using the Snackbar. It provides the user with a brief floating message.
It'll hide after some time unless the mouse is over it or it's the last thing touched on a touchscreen.

@inject ISnackbar Snackbar

<MudButton Variant="Variant.Filled" Color="Color.Primary" @onclick="@(() => Snackbar.Add("Simple Snackbar"))">
    Open Snackbar
</MudButton>
Html in messages

Snackbar messages are rendered as HTML using MarkupString.
However, make sure not to use user-provided input, as that's not very secure.

@inject ISnackbar Snackbar

<MudButton Variant="Variant.Filled" Color="Color.Primary" @onclick="@(() => Snackbar.Add($"<ul><li>Item {++count}</li><li>Item {++count}</li></ul>"))">
    Open Snackbar
</MudButton>
@code
{
    private int count = 0;
}

Copyright © 2020-2024 MudBlazor.

Powered by .NET 8.0.8

An error has occurred. This application may no longer respond until reloaded. Reload 🗙