Blazor Toast

    The Ignite UI for Blazor Toast component is primarily used for system messaging, push notifications, warning messages, and information. It cannot be dismissed by the user.

    Ignite UI for Blazor Toast Example

    This sample demonstrates how to create IgbToast component.

    Usage

    Before using the IgbToast, you need to register it as follows:

    IgbToastModule.Register(IgniteUIBlazor);
    

    You will also need to link an additional CSS file to apply the styling to the IgbCalendar component. The following needs to be placed in the wwwroot/index.html file in a Blazor Web Assembly project or the Pages/_Host.cshtml file in a Blazor Server project:

    <link href="_content/IgniteUI.Blazor/themes/light/bootstrap.css" rel="stylesheet" />
    
    <IgbButton @onclick=@OnToastButtonClick Variant=@ButtonVariant.Contained>Show Toast</IgbButton>
    <IgbToast @ref="ToastRef">Toast Message</IgbToast>
    
    @code {
        public IgbToast ToastRef { get; set; }
    
        protected override void OnInitialized()
        {
            IgbButtonModule.Register(IgniteUIBlazor);
            IgbToastModule.Register(IgniteUIBlazor);
        }
    
        public void OnToastButtonClick(MouseEventArgs args)
        {
            if(this.ToastRef != null)
            {
                this.ToastRef.Show();
            }
        }
    }
    

    Examples

    Properties

    Use the DisplayTime property to configure how long the toast component is visible. By default, it's set to 4000 milliseconds.

    By default, the toast component is hidden automatically after a period specified by the DisplayTime. You can use KeepOpen property to change this behavior. In this way, the toast will remain visible.

    <IgbButton @onclick=@OnToggleToastButtonClick Variant="ButtonVariant.Contained">Toggle Toast</IgbButton>
    <IgbButton @onclick=@OnToggleKeepOpenButtonClick Variant="ButtonVariant.Contained">Toggle KeepOpen Property</IgbButton>
    <IgbButton @onclick=@OnDisplayTimeButtonClick Variant="ButtonVariant.Contained">Set DisplayTime to 8000</IgbButton>
    
    <IgbToast @ref=ToastRef>Toast Message</IgbToast>
    
    @code {
        public IgbToast ToastRef{  get;  set; }
    
        protected override void OnInitialized()
        {
            IgbButtonModule.Register(IgniteUIBlazor);
            IgbToastModule.Register(IgniteUIBlazor);
        }
    
        public void OnToggleToastButtonClick(MouseEventArgs args)
        {
            if(this.ToastRef != null)
            {
                this.ToastRef.Toggle();
            }
        }
    
        public void OnToggleKeepOpenButtonClick(MouseEventArgs args)
        {
            if(this.ToastRef != null)
            {
                this.ToastRef.KeepOpen = !this.ToastRef.KeepOpen;
            }
        }
    
        public void OnDisplayTimeButtonClick(MouseEventArgs args)
        {
            if(this.ToastRef != null)
            {
                this.ToastRef.DisplayTime = 8000;
            }
        }
    }
    

    Styling

    You can style the toast using it's directly its tag selector:

    igc-toast {
        background: #011627;
        color: #ECAA53;
        outline-color: #ECAA53;
    }
    

    API Reference

    Additional Resources

    API Members