ManuHub.Blazor.Toast 2.0.0

dotnet add package ManuHub.Blazor.Toast --version 2.0.0
                    
NuGet\Install-Package ManuHub.Blazor.Toast -Version 2.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="2.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="2.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 2.0.0
                    
#r "nuget: ManuHub.Blazor.Toast, 2.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=2.0.0
                    
Install ManuHub.Blazor.Toast as a Cake Addin
#tool nuget:?package=ManuHub.Blazor.Toast&version=2.0.0
                    
Install ManuHub.Blazor.Toast as a Cake Tool

ManuHub.Blazor.Toast

ManuHub.Blazor.Toast is a Blazor component for displaying Bootstrap-based toast notifications with customizable types and positions.

⚛️ Features

  • Fully integrated with Bootstrap toasts
  • Supports different toast types (Success, Error, Info, Warning, Default)
  • Customizable toast positions (Top-Right, Top-Left, Bottom-Right, Bottom-Left, MiddleCenter, etc.)
  • JavaScript interop for seamless toast display
  • Compatible with Blazor Server, WebAssembly (WASM), and Hybrid apps

📦 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();

2️⃣ Include Bootstrap JS

In wwwroot/index.html (Blazor WASM) or Pages/_Host.cshtml (Blazor Server), or App.razor (Blazor Server), add:

File:

<script src="lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>

OR CDN:

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>

3️⃣ Import the Namespace

In _Imports.razor, add:

@using ManuHub.Blazor.Toast
@inject IToastService ToastService

4️⃣ Add the Toast Component

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

<ToastBS />

🚀 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="ShowSecondToast">Show Error Toast</button>

@code{
    public async Task ShowToast()
    {
        await ToastService.Show(title: "Hello", message: "Sample Notification.", timestamp: "now");
    }

    public async Task ShowSecondToast()
    {
        await ToastService.Show(title: "Error", message: "Something went wrong!", timestamp: "now",
            type: ToastType.Error, position: ToastPosition.TopCenter);
    }
}

🎨 Customization

Toast Types

ToastType.Default  // Light Toast
ToastType.Success  // Green Success Toast
ToastType.Error    // Red Error Toast
ToastType.Warning  // Yellow Warning Toast
ToastType.Info     // Blue Info Toast

Toast Positions

ToastPosition.BottomLeft    // Bottom Left
ToastPosition.BottomRight   // Bottom Right
ToastPosition.BottomCenter  // Bottom Center
ToastPosition.MiddleRight   // Middle Right
ToastPosition.MiddleCenter  // Middle Center
ToastPosition.MiddleCenter  // Middle 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. 
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
2.0.0 67 3/22/2025
1.0.0 64 3/15/2025