Toast

Non-intrusive notification messages

The Toast component displays brief, auto-dismissing notifications. Use toasts for success confirmations, error alerts, or informational messages that don't require user action.

Installation

bash
shellui add toast

Basic Usage

<Button OnClick="() => showToast = true">Show Toast</Button>

<Toast IsVisible="@showToast" IsVisibleChanged="@((v) => showToast = v)"
       Title="Success"
       Description="Your changes have been saved.">
</Toast>

@code {
    private bool showToast = false;
}

Variants

Default

<Button Variant="ButtonVariant.Outline" OnClick="() => show = true">Show toast</Button>

<Toast IsVisible="@show" IsVisibleChanged="@((v) => show = v)"
       Variant="default"
       Title="Notification"
       Description="You have a new message." />

@code {
    private bool show = false;
}

Destructive

<Button Variant="ButtonVariant.Outline" OnClick="() => show = true">Show error</Button>

<Toast IsVisible="@show" IsVisibleChanged="@((v) => show = v)"
       Variant="destructive"
       Title="Error"
       Description="Something went wrong. Please try again." />

@code {
    private bool show = false;
}

Success

<Button Variant="ButtonVariant.Outline" OnClick="() => show = true">Show success</Button>

<Toast IsVisible="@show" IsVisibleChanged="@((v) => show = v)"
       Variant="success"
       Title="Saved"
       Description="Your profile has been updated successfully." />

@code {
    private bool show = false;
}

Warning

<Button Variant="ButtonVariant.Outline" OnClick="() => show = true">Show warning</Button>

<Toast IsVisible="@show" IsVisibleChanged="@((v) => show = v)"
       Variant="warning"
       Title="Storage almost full"
       Description="You have used 90% of your storage." />

@code {
    private bool show = false;
}

Position

Control where toasts appear on screen:

<div class="flex gap-2">
    <Button Variant="ButtonVariant.Outline" OnClick="() => show = true">Top right</Button>
    <Button Variant="ButtonVariant.Outline" OnClick="() => show2 = true">Bottom left</Button>
</div>

<Toast IsVisible="@show" IsVisibleChanged="@((v) => show = v)"
       Position="top-right"
       Title="Top Right"
       Description="Toast appears in the top right." />

<Toast IsVisible="@show2" IsVisibleChanged="@((v) => show2 = v)"
       Position="bottom-left"
       Title="Bottom Left"
       Description="Toast appears in the bottom left." />

@code {
    private bool show = false;
    private bool show2 = false;
}

Duration

A toast hides itself after Duration milliseconds (5 seconds by default). Set Duration="0" to keep it open until it's closed.

<div class="flex gap-2">
  <Button Variant="ButtonVariant.Outline" OnClick="() => quick = true">Hide after 2 seconds</Button>
  <Button Variant="ButtonVariant.Outline" OnClick="() => sticky = true">Stay open</Button>
</div>

<Toast @bind-IsVisible="quick" Duration="2000" Title="Copied" Description="The link is on your clipboard." />
<Toast @bind-IsVisible="sticky" Duration="0" Title="Update available" Description="Close this toast to dismiss it." />

@code {
    private bool quick;
    private bool sticky;
}

With Custom Content

<Toast IsVisible="@show" IsVisibleChanged="@((v) => show = v)" Title="New Update">
  <div class="flex items-center gap-2">
    <p class="text-sm">Version 2.0 is now available.</p>
    <Button Size="ButtonSize.Sm" OnClick="HandleUpdate">Update</Button>
  </div>
</Toast>

@code {
    private bool show = false;
    private void HandleUpdate() { show = false; }
}

Multiple Toasts

Stack multiple toasts with a service pattern:

<Button OnClick="ShowSuccess">Success</Button>
<Button OnClick="ShowError">Error</Button>

<Toast IsVisible="@successVisible" IsVisibleChanged="@((v) => successVisible = v)"
       Variant="success" Title="Done!" Description="Operation completed." />

<Toast IsVisible="@errorVisible" IsVisibleChanged="@((v) => errorVisible = v)"
       Variant="destructive" Title="Failed" Description="Operation failed." />

@code {
    private bool successVisible = false;
    private bool errorVisible = false;

    private void ShowSuccess() => successVisible = true;
    private void ShowError() => errorVisible = true;
}

API Reference

Property Type Default Description
IsVisible bool false Controls toast visibility
IsVisibleChanged EventCallback<bool> — Callback when visibility changes
Title string? null Toast title
Description string? null Toast description text
Variant string "default" Visual style: default, destructive, success, warning
Position string "bottom-right" Screen position: top-left, top-right, bottom-left, bottom-right
Duration int 5000 Milliseconds before the toast hides itself; 0 keeps it open
ChildContent RenderFragment null Custom content
Class string? null Additional CSS classes

Accessibility

The Toast component includes:

  • role="status" with aria-live="polite" for screen readers
  • Close button with aria-label
  • Auto-dismiss with configurable duration
  • Keyboard dismissible via close button
  • Respects prefers-reduced-motion

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.