BlazorBootstrapToasts 1.0.3

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

blazor-bootstrap-toasts

Easy to use toast component based on bootstrap alerts. Only C# and CSS. No Javascript.

demo: http://toasts.kruki.at/ source code and working example code: https://gitlab.com/tkruk34/blazor-bootstrap-toasts

how to use

There are 2 possibilities how to use blazor-bootstrap-toasts.

use as single component

To use the toast component just insert the toast component like this:

<Toast @ref="Toast"></Toast>

Then add a reference to the toast in the @code-section like this:

public Toast Toast { get; set; }

Now you can call the from whereever you want in the scope like this:

Toast.Show("success","my message bla bla...",3000)

use a singleton (as service)

First of all you have to register the included service in your program.cs like this:

program.cs

public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<App>("#app");

            builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
            builder.Services.AddSingleton<IToastService, ToastService>();

            await builder.Build().RunAsync();
        }

Then you have to add a toast component to the service. To use the Service in your whole application, just add it in the app.razor component.

@using BlazorBootstrapToasts

@inject IToastService ToastService

<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
    </Found>
    <NotFound>
        <LayoutView Layout="@typeof(MainLayout)">
            <p>Sorry, there's nothing at this address.</p>
        </LayoutView>
    </NotFound>
</Router>

<Toast @ref="Toast"></Toast>

@code{
    private Toast Toast { get; set; }

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            ToastService.RegisterComponent(Toast);
        }
    }
}

Now you can inject the service whereever you want and call the Show()-method on the service.

<button class="btn btn-block btn-success" onclick="@(() => {ToastService.Show("success", Message, Duration); })">Success</button>

use custom item template

<Toast @ref="Toast">
    <ToastContent Context="message">
        My message in the custom toast: <b>@message</b>
    </ToastContent>
</Toast>
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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 was computed.  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.

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.3 1,669 3/16/2021
1.0.2 489 3/16/2021
1.0.1 479 3/16/2021
1.0.0 532 3/16/2021