BlazorToastify 1.0.1

.NET Standard 2.0
dotnet add package BlazorToastify --version 1.0.1
NuGet\Install-Package BlazorToastify -Version 1.0.1
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="BlazorToastify" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorToastify --version 1.0.1
#r "nuget: BlazorToastify, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlazorToastify as a Cake Addin
#addin nuget:?package=BlazorToastify&version=1.0.1

// Install BlazorToastify as a Cake Tool
#tool nuget:?package=BlazorToastify&version=1.0.1

BlazorToastify

BlazorTostify is an open source AND javascript-free toast notification package for Blazor Framework.

Demo gif of BlazorToastify

Table of contents

  1. Getting started & Installation
  2. Usage
  3. Documentation

1. Getting Started & Installation

Link to package Install the package via NuGet Manager search or BlazorTostaify. You can also use powershell to install the package using following command.

Install-Package BlazorToastify

Or use the dotnet CLI.

dotnet add package BlazorToastify

1.1 Register the services

In order to use BlazorToastify service you will need to register it in Startup.ConfigureService method.

public void ConfigureServices(IServiceCollection services)
{
    services.AddToasts();
}

1.2 Add import

Add the following using statement to your _Imports.razor file.

@using BlazorToastify

1.3 Add toast container to your layout

Add <ToastContainer /> tag in your razor layout. For example: MainLayout.razor.

1.4 Add reference to CSS stylesheet

Add the following line at the END of your head tag to your _Host.cshtml (Blazor Server App) or index.html (Blazor WebAssembly).

<link href="_content/BlazorToastify/blazor-toastify-style.css" rel="stylesheet" />

2. Usage

If you want to show a toast you need to inject IToastService into the component/code where you want to trigger a toast. After injecting the service you can call the following method to trigger a toast.

await ToastService.AddToastAsync(
    message: "Hello I am a success toast!",
    type: "success",
    animation: "fade",
    autoClose: 5000
);
@page "/"
@inject IToastService ToastService;

<button class="btn btn-primary" @onclick="@(async () => await ToastService.AddToastAsync("Default Toast"))">Default</button>
<button class="btn btn-info" @onclick="@(async () => await ToastService.AddToastAsync("Info toast", "info", "fade"))">Info</button>
<button class="btn btn-success" @onclick="@(async () => await ToastService.AddToastAsync("Success Toast", "success"))">Success</button>
<button class="btn btn-warning" @onclick="@(async () => await ToastService.AddToastAsync("Warning Toast", "warning"))">Warning</button>
<button class="btn btn-danger" @onclick="@(async () => await ToastService.AddToastAsync("error Toast", "error", "bounce", 10000))">Error</button>

Examples are included in samples folder.

3. Documentation

3.1 AddToastAsync

Method is awaitable, it adds a toast in toast container.

  • Parameters
    • message: string, required // Message you want to display on the toast notification
    • type: string, not required - options: default, info, success, warning, error // Type of the toast notification
    • animation: string, not required - options: bounce, fade // Animation the toast notification will use
    • autoClose: int, not required - // Time for toast to be visible in MS
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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
1.0.1 1,416 1/10/2020
1.0.0 399 1/10/2020

Removed debug messages