Persilsoft.Toast.Blazor
1.0.6
See the version list below for details.
dotnet add package Persilsoft.Toast.Blazor --version 1.0.6
NuGet\Install-Package Persilsoft.Toast.Blazor -Version 1.0.6
<PackageReference Include="Persilsoft.Toast.Blazor" Version="1.0.6" />
paket add Persilsoft.Toast.Blazor --version 1.0.6
#r "nuget: Persilsoft.Toast.Blazor, 1.0.6"
// Install Persilsoft.Toast.Blazor as a Cake Addin #addin nuget:?package=Persilsoft.Toast.Blazor&version=1.0.6 // Install Persilsoft.Toast.Blazor as a Cake Tool #tool nuget:?package=Persilsoft.Toast.Blazor&version=1.0.6
Persilsoft.Toast.Blazor
A Toast library for Blazor and Razor Components applications.
Example First, you need to register the following group of services in the dependency container.
using ServiceCollectionExtensions;
builder.Services.AddToastService();
Then you need to add an Toast component in your razor view, for example in the MainLayout component.
@using Persilsoft.Toast.Blazor
<div class="page">
<div class="sidebar">
<NavMenu />
</div>
<main>
<article class="content px-4">
@Body
</article>
</main>
</div>
<Toast />
The Toast component optionally accepts the parameter Position.
This enumeration can take one of the following values:
ToastPosition.TopLeft
ToastPosition.TopCenter
ToastPosition.TopRight (default value)
ToastPosition.MiddleLeft
ToastPosition.MiddleCenter
ToastPosition.MiddleRight
ToastPosition.BottomLeft
ToastPosition.BottomCenter
ToastPosition.BottomRight
<Toast Position="ToastPosition.BottomLeft" />
Finally you can use it.
@page "/toastdemo"
@using Persilsoft.Toast.Blazor
@inject IToastService ToastService;
<PageTitle>Toast Demo</PageTitle>
<h1>Toast Demo</h1>
<hr />
<button class="btn btn-info" @onclick=ShowToastInfo>Show toast info</button>
<button class="btn btn-success" @onclick=ShowToastSuccess>Show toast success</button>
<button class="btn btn-warning" @onclick=ShowToastWarning>Show toast warning</button>
<button class="btn btn-danger" @onclick=ShowToastError>Show toast danger</button>
@code {
private async Task ShowToastInfo()
{
await ToastService.ShowInfo("Info!", "This is the show toast info");
}
private async Task ShowToastSuccess()
{
await ToastService.ShowSuccess("Success!", "This is the show toast success", 3);
}
private async Task ShowToastWarning()
{
await ToastService.ShowWarning("Warning!", "This is the show toast warning");
}
private async Task ShowToastError()
{
await ToastService.ShowError("Danger!", "This is the show toast error", 0);
}
}
Product | Versions 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. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.