Skip to content

mariohik/Blazor.Toastr

Repository files navigation

Blazor.Toastr

Implementation of the Toastr Notifications in C# for Blazor via Interop

Blazor.Toastr

⚠️ Warning: This project is build on top of an experimental framework. There is a high propability that there will be breaking changes from version to version.

Installation

> dotnet add package Blazor.Toastr

OR

PM> Install-Package Blazor.Toastr

Nuget package & Release notes can be found here.

Usage

Add jQuery to index.html

<script src="js/jquery-3.3.1.min.js"></script>

Add INotificationService via DI

var serviceProvider = new BrowserServiceProvider(services =>
{
    services.AddToastr();
});

OR 

var serviceProvider = new BrowserServiceProvider(services =>
{
    services.AddToastr(new ToastrOptions { closeButton = true, hideDuration = 3000 });
});

Inject into component/pages

@using Blazor.Toastr
@inject IToastrService Toastr

Add OnClick Action

void AnyMethod() {
  Toastr.Show(Enums.ToastrType.Success, "This is a success message", "Title");
}

About

Add Toastr Notifications to a Blazor project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published