Blazor.Sonner
0.0.2
dotnet add package Blazor.Sonner --version 0.0.2
NuGet\Install-Package Blazor.Sonner -Version 0.0.2
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="Blazor.Sonner" Version="0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Blazor.Sonner" Version="0.0.2" />
<PackageReference Include="Blazor.Sonner" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Blazor.Sonner --version 0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Blazor.Sonner, 0.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Blazor.Sonner@0.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Blazor.Sonner&version=0.0.2
#tool nuget:?package=Blazor.Sonner&version=0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
https://github.com/user-attachments/assets/dc14fa06-aeae-422f-aa8a-b3be1ca540c4
Sonner for Blazor
An opinionated toast component for Blazor. A port of Emil Kowalski's Sonner.
Installation
dotnet add package Blazor.Sonner
Register the service in the DI container.
using Blazor.Sonner.Extensions;
// ...
builder.Services.AddSonner();
Add the styles to the HTML.
<link href="_content/Blazor.Sonner/styles.css" rel="stylesheet" />
Usage
Render the toaster in the root of your app.
@using Blazor.Sonner
@inject ToastService Toast
<Toaster />
<button @onclick="@(() => Toast.Show("My first toast"))">
Give me a toast
</button>
API Reference (in progress)
ToastService
Method | Description |
---|---|
Show | Displays a default toast with the specified title and optional data. |
Success | Displays a success toast with the specified title and optional data. |
Warning | Displays a warning toast with the specified title and optional data. |
Error | Displays an error toast with the specified title and optional data. |
Info | Displays an informational toast with the specified title and optional data. |
RemoveAll | Removes all currently displayed toasts. |
Toaster (Global settings)
Parameter | Description | Type | Default |
---|---|---|---|
Id | Gets or sets the unique identifier for the toaster instance. | string? |
- |
Position | Gets or sets the position on the screen where toasts are displayed. | ToastPosition |
ToastPosition.BottomRight |
Duration | Gets or sets the duration each toast is displayed before it is automatically dismissed. | TimeSpan |
4000 ms |
VisibleToasts | Gets or sets the maximum number of visible toasts. | int |
3 |
Gap | Gets or sets the spacing in pixels between toasts. | int |
14 |
Offset | Gets or sets the offset from the screen edges. | Offset |
- |
MobileOffset | Gets or sets the offset from the screen edges on mobile devices. | Offset |
- |
Expand | Gets or sets a value indicating whether toasts should be expanded by default. | bool |
false |
CloseButton | Gets or sets a value indicating whether to show a close button on toasts. | bool |
false |
RichColors | Gets or sets a value indicating whether to enable rich color styling for toasts. | bool |
false |
Dir | Gets or sets the document direction for the toast layout. | DocumentDirection |
DocumentDirection.Auto |
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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.19)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.