Persilsoft.Toast.Blazor
1.0.3
See the version list below for details.
dotnet add package Persilsoft.Toast.Blazor --version 1.0.3
NuGet\Install-Package Persilsoft.Toast.Blazor -Version 1.0.3
<PackageReference Include="Persilsoft.Toast.Blazor" Version="1.0.3" />
paket add Persilsoft.Toast.Blazor --version 1.0.3
#r "nuget: Persilsoft.Toast.Blazor, 1.0.3"
// Install Persilsoft.Toast.Blazor as a Cake Addin #addin nuget:?package=Persilsoft.Toast.Blazor&version=1.0.3 // Install Persilsoft.Toast.Blazor as a Cake Tool #tool nuget:?package=Persilsoft.Toast.Blazor&version=1.0.3
Persilsoft.Toast.Blazor
A Toast library for Blazor and Razor Components applications.
Example First, you need to register the component in the dependency injection service.
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 "/"
@inject IToastService ToastService
@using @using Persilsoft.Toast.Blazor
<PageTitle>Toast Blazor</PageTitle>
<h1>Toast Blazor example</h1>
<hr />
<button class="btn btn-info" @onclick=ShowToastInfo>Show toast info</button>
<button class="btn btn-warning" @onclick=ShowToastWarning>Show toast warning</button>
<button class="btn btn-danger" @onclick=ShowToastError>Show toast danger</button>
<button class="btn btn-success" @onclick=ShowToastSuccess>Show toast success</button>
@code {
private void ShowToastInfo()
{
ToastService.ShowInfo("Info!", "This is the show toast info");
}
private void ShowToastWarning()
{
ToastService.ShowWarning("Warning!", "This is the show toast warning");
}
private void ShowToastError()
{
ToastService.ShowError("Danger!", "This is the show toast error", 0);
}
private void ShowToastSuccess()
{
ToastService.ShowSuccess("Success!", "This is the show toast success");
}
}
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.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.