ARG.RABBI.Sonner.NetCore 1.0.5

dotnet add package ARG.RABBI.Sonner.NetCore --version 1.0.5
                    
NuGet\Install-Package ARG.RABBI.Sonner.NetCore -Version 1.0.5
                    
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="ARG.RABBI.Sonner.NetCore" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ARG.RABBI.Sonner.NetCore" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="ARG.RABBI.Sonner.NetCore" />
                    
Project file
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 ARG.RABBI.Sonner.NetCore --version 1.0.5
                    
#r "nuget: ARG.RABBI.Sonner.NetCore, 1.0.5"
                    
#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 ARG.RABBI.Sonner.NetCore@1.0.5
                    
#: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=ARG.RABBI.Sonner.NetCore&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=ARG.RABBI.Sonner.NetCore&version=1.0.5
                    
Install as a Cake Tool

Sonner.NetCore

GitHub

An elegant, robust, and lightweight toaster library for .NET Core MVC and Razor Pages. Inspired by the popular React library Sonner, but built from the ground up for backend-driven .NET web applications.

Sonner Demo (Preview of the Toast)

By ARG RABBI - Visit Profile


🚀 Features

  • Framework Support: Native support for .NET 5.0, 6.0, 7.0, 8.0, and .NET 9.0.
  • Full Positioning Support: Choose from 6 different positions.
  • Stacking & Expanding: Sophisticated stacking logic that expands on hover.
  • Rich Colors: Vibrant background colors for success, error, info, and warning states.
  • Dark Theme: Built-in support for dark mode.
  • Close Button: Optional dismiss button for individual toasts.
  • No React/Vue required! Pure Vanilla JS and CSS natively integrated into .NET.
  • Trigger Toasts from C#: Seamlessly add toasts directly from your Controllers.
  • Tag Helper Integration: Clean syntax in Razor views.

📦 Installation

Via NuGet Package Manager Console:

Install-Package ARG.RABBI.Sonner.NetCore

Via .NET CLI:

dotnet add package ARG.RABBI.Sonner.NetCore

💻 Setup Guide

Follow these simple steps to integrate Sonner into your .NET application.

1. Register the Middleware

This serves the embedded assets. Choose the guide based on your project style:

Modern Hosting Style (.NET 6, 7, 8, & 9)

Usually found in Program.cs (Top-level statements).

app.UseRouting();

// Add this line after UseRouting() but before UseAuthorization()
app.UseSonner(); 

app.UseAuthorization();
Legacy Hosting Style (.NET 5 and below)

Usually found in Startup.cs (Configure method).

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    app.UseRouting();
    
    // Add this line
    app.UseSonner(); 

    app.UseAuthorization();
}

2. Add Tag Helpers (_ViewImports.cshtml)

Add the Sonner namespace to your Views/_ViewImports.cshtml:

@addTagHelper *, Sonner.NetCore

3. Initialize in Layout (_Layout.cshtml)

Include the CSS in <head> and the script + tag helper before </body>.

<head>
    <link rel="stylesheet" href="~/sonner.css" />
</head>
<body>
    @RenderBody()

    <script src="~/sonner.js"></script>
    <sonner-toaster 
        position="BottomRight" 
        expand="false" 
        rich-colors="true" 
        close-button="true" 
        theme="light">
    </sonner-toaster>
</body>

🎨 Positioning

Sonner.NetCore supports 6 positions out of the box:

  • TopLeft
  • TopCenter
  • TopRight
  • BottomLeft
  • BottomCenter
  • BottomRight
<sonner-toaster position="TopCenter"></sonner-toaster>

🔥 Usage (Backend)

Trigger toasts directly from your Controllers using extension methods.

public IActionResult Save()
{
    // Simple toast
    this.AddSuccessToast("Data saved successfully!");
    
    // Toast with title
    this.AddErrorToast("Please check your input.", "Validation Error");
    
    // Toast with custom position override
    this.AddWarningToast("Attention required!", position: ToasterPosition.TopRight);
    
    // Custom toast
    this.AddToast("Info message", ToastType.Info, position: ToasterPosition.BottomLeft);
    
    return RedirectToAction("Index");
}

⚡ Usage (Frontend)

You can also trigger toasts manually from JavaScript using the global window.sonnerInstance. Per-toast position overrides the global configuration.

// Success toast with default position
window.sonnerInstance.toast('Operation completed!', 'Success', 'Success Title');

// Error toast with specific position override
window.sonnerInstance.toast('Something went wrong.', 'Error', null, 'top-center');

📜 Publishing Update

To publish a new version:

  1. Update version in .csproj.
  2. Run dotnet pack -c Release.
  3. Upload .nupkg to NuGet.org.

Crafted with ❤️ by ARG RABBI for the robust .NET ecosystem.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 129 3/4/2026
1.0.4 113 3/4/2026
1.0.3 106 3/4/2026
1.0.2 112 3/4/2026
1.0.1 112 3/4/2026
1.0.0 110 3/4/2026