All Projects → Blazored → Toast

Blazored / Toast

Licence: mit
A JavaScript free toast library for Blazor and Razor Component applications

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Toast

Menu
A JavaScript free menu library for Blazor and Razor Components applications.
Stars: ✭ 118 (-60.14%)
Mutual labels:  hacktoberfest, nuget, razor
Modal
A powerful and customizable modal implementation for Blazor applications.
Stars: ✭ 406 (+37.16%)
Mutual labels:  hacktoberfest, nuget, razor
Burnttoast
Module for creating and displaying Toast Notifications on Microsoft Windows 10.
Stars: ✭ 796 (+168.92%)
Mutual labels:  hacktoberfest, toast
Bulma Toast
Bulma's pure JavaScript extension to display toasts
Stars: ✭ 93 (-68.58%)
Mutual labels:  hacktoberfest, toast
Sessionstorage
A library to provide access to session storage in Blazor applications
Stars: ✭ 132 (-55.41%)
Mutual labels:  hacktoberfest, nuget
Strongbox
Strongbox is an artifact repository manager.
Stars: ✭ 412 (+39.19%)
Mutual labels:  hacktoberfest, nuget
Localstorage
A library to provide access to local storage in Blazor applications
Stars: ✭ 425 (+43.58%)
Mutual labels:  hacktoberfest, nuget
Colore
A powerful C# library for Razer Chroma's SDK
Stars: ✭ 121 (-59.12%)
Mutual labels:  hacktoberfest, nuget
Fluentvalidation
A library for using FluentValidation with Blazor
Stars: ✭ 184 (-37.84%)
Mutual labels:  hacktoberfest, nuget
Typeahead
Typeahead control for Blazor applications
Stars: ✭ 226 (-23.65%)
Mutual labels:  hacktoberfest, nuget
Mond
A scripting language for .NET Core
Stars: ✭ 237 (-19.93%)
Mutual labels:  hacktoberfest, nuget
Razor.SweetAlert2
A Razor class library for interacting with SweetAlert2
Stars: ✭ 98 (-66.89%)
Mutual labels:  toast, razor
32feet
Personal Area Networking for .NET
Stars: ✭ 395 (+33.45%)
Mutual labels:  hacktoberfest, nuget
Quartznet
Quartz Enterprise Scheduler .NET
Stars: ✭ 4,825 (+1530.07%)
Mutual labels:  hacktoberfest, nuget
Chartjs.blazor
Brings Chart.js charts to Blazor
Stars: ✭ 402 (+35.81%)
Mutual labels:  nuget, razor
Msbuild.sdk.sqlproj
An MSBuild SDK that provides similar functionality to SQL Server Data Tools (.sqlproj) projects
Stars: ✭ 142 (-52.03%)
Mutual labels:  hacktoberfest, nuget
Blazor.PersianDatePicker
A free JavaScript Jalali (Persian) and Gregorian (Miladi) dual datepicker library for Blazor applications
Stars: ✭ 40 (-86.49%)
Mutual labels:  nuget, razor
Blazorcontextmenu
A context menu component for Blazor !
Stars: ✭ 257 (-13.18%)
Mutual labels:  nuget, razor
Javis.jl
Julia Animations and Visualizations
Stars: ✭ 289 (-2.36%)
Mutual labels:  hacktoberfest
Awesome Frameworkless
A collection of awesome things regarding Frameworkless
Stars: ✭ 293 (-1.01%)
Mutual labels:  hacktoberfest

Blazored Toast

This is a JavaScript free toast implementation for Blazor and Razor Components applications. It supports icons that are either specified by class name (such as fontawesome) or by a specified element (Material Design).

Build & Test Main

Nuget

Screenshot of component in action

Getting Setup

You can install the package via the NuGet package manager just search for Blazored.Toast. You can also install via powershell using the following command.

Install-Package Blazored.Toast

Or via the dotnet CLI.

dotnet add package Blazored.Toast

1. Register Services

You will need to register the Blazored Toast service in your application

Blazor Server

Add the following line to your applications Startup.ConfigureServices method.

public void ConfigureServices(IServiceCollection services)
{
    services.AddBlazoredToast();
}

Blazor WebAssembly

Add the following line to your applications Program.Main method.

builder.Services.AddBlazoredToast();

2. Add Imports

Add the following to your _Imports.razor

@using Blazored.Toast
@using Blazored.Toast.Services

3. Register and Configure Toasts Component

Add the <BlazoredToasts /> tag into your applications MainLayout.razor.

Toasts are configured using parameters on the <BlazoredToasts /> component. The following options are available.

  • InfoClass
  • InfoIcon
  • SuccessClass
  • SuccessIcon
  • WarningClass
  • WarningIcon
  • ErrorClass
  • ErrorIcon
  • IconType (Default: IconType.FontAwesome)
  • Position (Default: ToastPosition.TopRight)
  • Timeout (Default: 5)

By default, you don't need to provide any settings everything will just work. But if you want to add icons to toasts or override the default styling then you can use the options above to do that.

For example, to add an icon from Font Awesome to all success toasts you can do the following.

<BlazoredToasts SuccessIcon="fa fa-thumbs-up"/>

Setting the position also requires a reference to Blazored.Toast.Configuration, for example:

@using Blazored.Toast.Configuration

<BlazoredToasts Position="ToastPosition.BottomRight"
                Timeout="10"
                IconType="IconType.FontAwesome"
                SuccessClass="success-toast-override"
                SuccessIcon="fa fa-thumbs-up"
                ErrorIcon="fa fa-bug" />

The example above is from the client side samples.

<BlazoredToasts Position="ToastPosition.BottomRight"
                Timeout="10"
                IconType="IconType.Material"
                ErrorIcon="error_outline"
                InfoIcon="school"
                SuccessIcon="done_outline"
                WarningIcon="warning" />

The example above is from the server side samples and demonstrates the use of Material Design icons.

4. Add reference to style sheet(s)

Add the following line to the head tag of your _Host.cshtml (Blazor Server app) or index.html (Blazor WebAssembly). The blazored-toast.css includes the open-iconic-bootstrap.min.css.

We ship both minified and unminified CSS.

For minifed use:

<link href="_content/Blazored.Toast/blazored-toast.min.css" rel="stylesheet" />

For unminifed use:

<link href="_content/Blazored.Toast/blazored-toast.css" rel="stylesheet" />

Presumably, if you want to use the Material Icons your project already includes some form of the icons. If not see Material Design Icons for the available alternatives.

Usage

In order to show a toast you have to inject the IToastService into the component or service you want to trigger a toast. You can then call one of the following methods depending on what kind of toast you want to display, passing in a message and an optional heading.

  • ShowInfo
  • ShowSuccess
  • ShowWarning
  • ShowError
@page "/toastdemo"
@inject IToastService toastService

<h1>Toast Demo</h1>

To show a toast just click one of the buttons below.

<button class="btn btn-info" @onclick="@(() => toastService.ShowInfo("I'm an INFO message"))">Info Toast</button>
<button class="btn btn-success" @onclick="@(() => toastService.ShowSuccess("I'm a SUCCESS message with a custom title", "Congratulations!"))">Success Toast</button>
<button class="btn btn-warning" @onclick="@(() => toastService.ShowWarning("I'm a WARNING message"))">Warning Toast</button>
<button class="btn btn-danger" @onclick="@(() => toastService.ShowError("I'm an ERROR message"))">Error Toast</button>

Full examples for client and server-side Blazor are included in the samples.

Show Progress Bar

You can display a progress bar which gives a visual indicator of the time remaining before the toast will disappear. In order to show the progress bar set the ShowProgressBar parameter to true.

<BlazoredToasts Position="ToastPosition.BottomRight"
                Timeout="10"
                ShowProgressBar="true" />

Remove Toasts When Navigating

If you wish to clear any visible toasts when the user navigates to a new page you can enable the RemoveToastsOnNavigation parameter. Setting this to true will remove any visible toasts whenever the LocationChanged event fires.

FAQ

The toasts are not showing

  • Check the z-index of your other DOM Elements, make sure that the .blazored-toast-container has a higher z-index than the other components.

I upgraded my version of Blazored Toasts and I have errors in my razor file where I declare the BlazoredToasts component.

  • The parameter IconType is a mandatory parameter. An exception will be thrown if any icon is specified.
  • Check the icon parameter names if you have upgraded from a version prior to 2.0.10. Previous to this version the icons supported were specified by class and the parameters were of the form SuccessIconClass. With the addition of Material icon support the parameter form is now simply SuccessIcon.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].