ManuHub.Blazor.Toast 3.0.0

dotnet add package ManuHub.Blazor.Toast --version 3.0.0
                    
NuGet\Install-Package ManuHub.Blazor.Toast -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ManuHub.Blazor.Toast" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ManuHub.Blazor.Toast" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ManuHub.Blazor.Toast" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ManuHub.Blazor.Toast --version 3.0.0
                    
#r "nuget: ManuHub.Blazor.Toast, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ManuHub.Blazor.Toast&version=3.0.0
                    
Install ManuHub.Blazor.Toast as a Cake Addin
#tool nuget:?package=ManuHub.Blazor.Toast&version=3.0.0
                    
Install ManuHub.Blazor.Toast as a Cake Tool

Static Badge NuGet Version .NET

ManuHub.Blazor.Toast

ManuHub.Blazor.Toast is a Blazor conponent for displaying multiple toast notifications with Bootstrap-based styles and Tailwind Styles and Default styles with customizable options and positions. Without javaScript for default, it provides a simple and elegant way to show notifications in your Blazor applications. Other styles are also available, including Bootstrap and Tailwind CSS. Automatically includes the required CSS and JS files from CDN, you can set it the configurations in the Program.cs file.

✨ Features

  • ✅ Easy to use
  • ✅ Bootstrap 5.3.3 compatible
  • ✅ Fully customizable
  • ✅ Multiple toast types (Success, Error, Warning, Info)
  • ✅ Multiple toast positions (Top, Bottom, Left, Right, Center)
  • ✅ Multiple styles (Tailwind, Bootstrap, Default)
  • ✅ Animations
  • ✅ Hover pause
  • ✅ Close buttons
  • ✅ Queue + timeouts
  • ✅ Per-toast duration & max toasts
  • ✅ Compatible with Blazor Server, WebAssembly (WASM), and Hybrid apps

🎨 Toast Styles

  • Bootstrap: Uses Bootstrap 5.3.3 styles for a modern look.
  • Tailwind: Uses Tailwind CSS for a clean and minimalistic design.
  • Default: A simple and classic modern design without any framework dependencies.

⚛️ Toast Options

  • ToastStyle: The style of the toast (Bootstrap, Tailwind, Default).
  • Position: The position of the toast on the screen (Top, Bottom, Left, Right, Center).
  • MaxToasts: The maximum number of toasts that can be displayed at once.
  • ShowCloseButton: Whether to show a close button on the toast.
  • IncludeCDN: Whether to include Bootstrap/Tailwind CSS and JS from CDN.

📦 Installation

Install the NuGet package:

 dotnet add package ManuHub.Blazor.Toast

🛠 Setup

1️⃣ Register the Service

In Program.cs, add the toast service:

using ManuHub.Blazor.Toast;

builder.Services.AddBlazorToast();

Toast options can be configured globally in Program.cs:

builder.Services.AddBlazorToast(options =>
{
    options.MaxToasts = 5; // Maximum number of toasts to show at once
    options.Position = ToastPosition.TopRight; // Default position for all toasts
    options.ToastStyle = ToastStyle.Bootstrap; // Default style for all toasts 
    options.ShowCloseButton = true; // Show close button on toasts
    options.IncludeCDN = true; // Use CDN for Bootstrap/Tailwind CSS and JS
});

2 Import the Namespace

In _Imports.razor, add:

@using ManuHub.Blazor.Toast
@inject IToastService ToastService

3 Add the Toast Component

In MainLayout.razor, include the <ToastHost/> component:

<ToastHost />

🚀 Usage

✅ Show Toast in a Component

In Home.razor, use the ToastService to trigger notifications:

@page "/"

<PageTitle>Home</PageTitle>

<h1>Hello, world!</h1>

<button class="btn btn-primary" @onclick="ShowToast">Show Toast</button>
<button class="btn btn-danger" @onclick="ShowInfoToast">Show Info Toast</button>
<button class="btn btn-success" @onclick="ShowSuccessToast">Show Success Toast</button>
<button class="btn btn-warning" @onclick="ShowWarningToast">Show Warning Toast</button>
<button class="btn btn-info" @onclick="ShowErrorToast">Show Error Toast</button>>

@code{
    public void ShowToast()
    {
        ToastService.ShowToast("Sample Notification.", ToastLevel.Info, 5000);
    }

    public async Task ShowInfoToast()
    {
        ToastService.Info("Sample Notification."); // Default duration is 5000ms
    }

    public async Task ShowSuccessToast()
    {
        ToastService.Success("Sample Notification.",7000);
    }

    public async Task ShowWarningToast()
    {
        ToastService.Warning("Sample Notification.",4000);
    }

    public async Task ShowErrorToast()
    {
        ToastService.Error("Sample Notification.",6000);
    }
}

🎨 Customization

Toast Level

Configure the toast level to change the color and icon of the toast:

ToastLevel.Success  // Green Success Toast
ToastLevel.Error    // Red Error Toast
ToastLevel.Warning  // Yellow Warning Toast
ToastLevel.Info     // Blue Info Toast

Toast Positions

Configure the toast position to change where the toast appears on the screen:

ToastPosition.BottomLeft    // Bottom Left
ToastPosition.BottomRight   // Bottom Right
ToastPosition.BottomCenter  // Bottom Center
ToastPosition.TopLeft       // Top Left
ToastPosition.TopRight      // Top Right
ToastPosition.TopCenter     // Top Center

📜 License

MIT License

✨ Contributions

Feel free to submit issues or pull requests to improve the package!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 230 5/14/2025
2.0.0 83 3/22/2025
1.0.0 74 3/15/2025