@using Astrol.Entities.Basic.Static.Notification@using Astrol.Component.Basic.Button@using Astrol.Entities.Basic.UI@using Astrol.JSInterop.Base@inject AstrolJSInterop jsI <AstrolButton OnClick="x=>ShowMinimalNotification()" Style="AstrolStyle.Blue" Text="Click me" />@code { private async Task ShowMinimalNotification() { await Task.Delay(400); await jsI.Notification("Minimum notification: Base".NotificationBase()); await Task.Delay(400); await jsI.Notification("Minimum notification: None".NotificationNone()); await Task.Delay(400); await jsI.Notification("Minimum notification: Info".NotificationInfo()); await Task.Delay(400); await jsI.Notification("Minimum notification: Error".NotificationError()); await Task.Delay(400); await jsI.Notification("Minimum notification: Warning".NotificationWarning()); await Task.Delay(400); await jsI.Notification("Minimum notification: Success".NotificationSuccess()); }}@using Astrol.Component.Basic.Button@using Astrol.Entities.Basic.UI@using Astrol.JSInterop.Base@inject AstrolJSInterop jsI <AstrolButton OnClick='x => ShowNotification("Hello World!", "astrol-ok", AstrolStyle.Blue)' Style='AstrolStyle.Blue' Text='Click me' />@code { private async Task ShowNotification(string message,string icon, AstrolStyle type, bool outline = false) { await jsI.Notification(new Notification { Type = type, Icon = icon, Message = message, Outline = outline, }); }}// Program.csusing Astrol.Component.Basic;builder.Services.AddAstrolBasic();@using Astrol.Component.Basic.Toast@using Astrol.Component.Basic.Modal@inject IAstrolToast Toast@inject IAstrolModal Modal@* AstrolLayoutMenu already includes <AstrolToastHost /> and <AstrolModalHost /> *@@code { private void Save() { Toast.Success("Saved"); Toast.Error("Could not save\nPlease try again"); } private async Task Delete() { if (await Modal.ConfirmAsync("Are you sure?", "The item will be deleted.")) Toast.Success("Deleted"); } private async Task Edit() { // EditUser: your component; it closes itself with [CascadingParameter] AstrolModalReference var result = await Modal.ShowAsync<EditUser>("Edit", new Dictionary<string, object?> { ["Id"] = 5 }); if (!result.Cancelled) { var user = result.GetData<User>(); } }}IAstrolToast service (recommended): @inject IAstrolToast Toast and Toast.Success / Error / Warning / Info("message", seconds) (default 5 / 8 / 6 / 5 seconds), Toast.Show("message", style, icon, seconds, outline), Toast.Show(notification) with the model below, or Toast.Clear(). It is rendered by Blazor, pauses on hover, can be closed with the keyboard, follows the theme and stays above modals. Requires AddAstrolBasic(); AstrolLayoutMenu already includes the host (without it, add <AstrolToastHost /> once, e.g. in MainLayout; with no host the JS notification is used).
String extensions (@using Astrol.Entities.Basic.Static.Notification), for jsI.Notification(...) or Toast.Show(...): "text".NotificationSuccess(), NotificationError, NotificationWarning, NotificationInfo, NotificationNone and NotificationBase, with optional parameters (icon = "astrol-warning", outline = true, time = 5, allowHtml = false).
Notification model (also for jsI.Notification(...)):