Toasts

Toasts pop up quick notifications.

Getting Started

To use toasts you first need to create a ToastGroup. This is a container for all of your toasts.

If you want toasts to show everywhere place the ToastGroup in your main layout.

<ToastGroup></ToastGroup>

You can inject the ToastService into your component or a background worker and create toasts.

@inject ToastService ToastService

<button class="btn btn-primary" @onclick="AddToast">Add Toast!</button>

@code {
    public async Task AddToast()
    {
        var toast = new Toast()
        {
            Dismissable = true,
            Duration = TimeSpan.FromSeconds(5),
            Message = "Yay toasts!",
            Class = "alert-success"
        };

        await ToastService.CreateAsync(toast);
    }
}
            

Result