Skip to content
GitHub11 stars

A succinct message that is displayed temporarily.

@inject ToastManager Toasts

<Button Variant="ButtonVariant.Outline" @onclick="ShowToast">Show Toast</Button>

Installation

Run the following command:

dnx Blazix.Cli add toast

Register a ToastManager for each user.

Program.cs
builder.Services.AddRazorComponents().AddInteractiveServerComponents();

builder.Services.AddScoped<ToastManager>();

With a .Client project (WebAssembly or Auto), register it in both projects' Program.cs.

Add the Toaster component.

Components/Layout/MainLayout.razor
@inherits LayoutComponentBase

<main>@Body</main>
<Toaster />

The layout has to be interactive. If only your pages have a render mode, give the Toaster one: <Toaster @rendermode="InteractiveAuto" />. See Render Modes.

Usage

Inject the ToastManager and add toasts to it. The Toaster in your layout shows them.

@inject ToastManager Toasts

<Button @onclick="Notify">Show Toast</Button>

@code {
    private void Notify() =>
        Toasts.Add(new ToastOptions
        {
            Title = "Event created",
            Description = "Sunday, December 3 at 9:00 AM",
        });
}

Types

Set the Type option to render a status icon. The built-in renderer recognizes success, info, warning, error, and loading.

@inject ToastManager Toasts

<div class="flex flex-wrap gap-2">

Action

Set ActionLabel and OnAction to render an action button. The toast closes after the action runs.

Toasts.Add(new ToastOptions
{
    Title = "Event created",
    ActionLabel = "Undo",
    OnAction = UndoAsync,
});

Promise

Use ToastManager.Promise to update one toast as an asynchronous task moves through loading, success, and error states.

@inject ToastManager Toasts

<Button Variant="ButtonVariant.Outline" @onclick="ShowToastAsync">Create Event</Button>

API Reference

Toast

ParameterTypeDefault
Itemrequired ToastObject -
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

ToastAction

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

ToastClose

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

ToastContent

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

ToastDescription

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

ToastIcon

ParameterTypeDefault
Type ToastIconType? -

ToastPortal

ParameterTypeDefault
ChildContent RenderFragment? -

ToastProvider

ParameterTypeDefault
ToastManager ToastManager? -
Timeout int 5000
Limit int 3
ChildContent RenderFragment? -

ToastTitle

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

ToastViewport

ParameterTypeDefault
Template RenderFragment<ToastObject>? -
SwipeDirections IReadOnlyList<string> -
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

Toaster

ParameterTypeDefault
ToastManager ToastManager? -
Timeout int 5000
Limit int 3
ChildContent RenderFragment? -

Changelog

2026-11-24 ToastIcon type

ToastIcon's Type is now a ToastIconType: ToastIconType.Success, Info, Warning, Error, or Loading. ToastOptions.Type still takes a string, so Type = "success" keeps working.

<ToastIcon Type="ToastIconType.Success" />

If you render ToastIcon yourself, run dnx Blazix.Cli diff toast to see your changes, then dnx Blazix.Cli add toast --overwrite.