Sotsera.Blazor.Toaster 0.9.0-preview-3

.NET Standard 2.0
This is a prerelease version of Sotsera.Blazor.Toaster.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Sotsera.Blazor.Toaster --version 0.9.0-preview-3
NuGet\Install-Package Sotsera.Blazor.Toaster -Version 0.9.0-preview-3
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="Sotsera.Blazor.Toaster" Version="0.9.0-preview-3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sotsera.Blazor.Toaster --version 0.9.0-preview-3
#r "nuget: Sotsera.Blazor.Toaster, 0.9.0-preview-3"
#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 Sotsera.Blazor.Toaster as a Cake Addin
#addin nuget:?package=Sotsera.Blazor.Toaster&version=0.9.0-preview-3&prerelease

// Install Sotsera.Blazor.Toaster as a Cake Tool
#tool nuget:?package=Sotsera.Blazor.Toaster&version=0.9.0-preview-3&prerelease

Sotsera.Blazor.Toaster

A Blazor port of Toastr.js in pure .Net.

The transitions are implemented using System.Threading.Timer so this library should be used only by client side blazor (webassembly).

Razor components currently cannot reference static assets from component libraries. As a temporary workaround the css can be saved into the server project wwwroot and loaded by the index.html with something like <link href="toastr.min.css" rel="stylesheet"/>.

The sample project has been published here.

Changes

version 0.9.0-preview-3

  • fixes issue #19 - exclude razor files from the nuget package

version 0.9.0-preview-2

See the RELEASE-NOTES for the previous versions.

Configuration

Installation

Install-Package Sotsera.Blazor.Toaster

Dependency injection configuration

services.AddToaster(config =>
{
    //example customizations
    config.PositionClass = Defaults.Classes.Position.TopRight;
    config.PreventDuplicates = true;
    config.NewestOnTop = false;
});

Main toaster component

The toast container must be added to the App.razor component or to another component always loaded in the application like MainLayout.razor. It is important to have exactly one instance of this component rendered in the application tree at any given time.

@using Sotsera.Blazor.Toaster
<ToastContainer />

Usage

In a component

@inject Sotsera.Blazor.Toaster.IToaster Toaster

In a class

[Inject] 
protected Sotsera.Blazor.Toaster.IToaster Toaster { get; set; }

then call one of the display methods:

Toaster.Info("toast body text");
Toaster.Success("toast body text");
Toaster.Warning("toast body text");
Toaster.Error("toast body text");

Each of these methods can accept a title and an action for the toast specific configuration

Toaster.Info("toast body text");
Toaster.Info("toast body text", "toast title");
Toaster.Info("toast body text", "toast title", options =>
{
    options.Clicked += toast => Console.WriteLine($"Toast '{toast.Message}' Clicked!");
});

Credits

This is a simple attempt to port Toastr.js to Blazor.

Currently the css styles used are literally COPIED from Toastr.js.

The logo has been made by Freepik from Flaticon and is licensed by CC 3.0 BY

License

Sotsera.Blazor.Toaster is licensed under MIT license

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 (1)

Showing the top 1 NuGet packages that depend on Sotsera.Blazor.Toaster:

Package Downloads
BlazingComponents.Lib

Components, Controller, Service and State Provider for Asp.NetCore Blazor.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Sotsera.Blazor.Toaster:

Repository Stars
ArduPilot/MissionPlanner
Mission Planner Ground Control Station (c# .net)
Version Downloads Last updated
3.0.0 115,014 1/3/2020
2.0.0 1,526 12/5/2019
2.0.0-beta1 459 11/30/2019
1.0.0 5,221 9/28/2019
1.0.0-preview9.1 1,179 9/4/2019
1.0.0-preview.8.1 446 8/14/2019
0.11.1 485 7/30/2019
0.10.1 341 7/13/2019
0.10.0 1,995 6/16/2019
0.9.0-preview-3 762 4/25/2019
0.9.0-preview-1 702 3/12/2019
0.8.0-preview-4 560 2/14/2019
0.6.1 1,200 2/12/2019
0.6.0 2,923 10/4/2018
0.5.3 842 8/25/2018
0.5.2 706 7/30/2018
0.5.1 620 7/26/2018
0.4.1 640 7/23/2018
0.4.0 791 7/18/2018