alexa
menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class ToastButton

    Provides configuration data for action buttons within the Toast notification component.

    Inheritance
    object
    ComponentBase
    OwningComponentBase
    SfOwningComponentBase
    ToastButton
    Implements
    IComponent
    IHandleEvent
    IHandleAfterRender
    IDisposable
    Inherited Members
    ComponentBase.Assets
    ComponentBase.AssignedRenderMode
    ComponentBase.BuildRenderTree(RenderTreeBuilder)
    ComponentBase.DispatchExceptionAsync(Exception)
    ComponentBase.InvokeAsync(Action)
    ComponentBase.InvokeAsync(Func<Task>)
    ComponentBase.OnAfterRender(bool)
    ComponentBase.OnAfterRenderAsync(bool)
    ComponentBase.OnInitialized()
    ComponentBase.OnParametersSet()
    ComponentBase.OnParametersSetAsync()
    ComponentBase.RendererInfo
    ComponentBase.SetParametersAsync(ParameterView)
    ComponentBase.ShouldRender()
    ComponentBase.StateHasChanged()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    OwningComponentBase.IsDisposed
    OwningComponentBase.ScopedServices
    Namespace: Syncfusion.Blazor.Notifications
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ToastButton : SfOwningComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
    Remarks

    The ToastButton class enables customization of buttons displayed in toast notifications, including appearance, behavior, and user interaction handling. This component inherits from SfOwningComponentBase and provides comprehensive button configuration options.

    Examples

    A simple Toast button configuration.

    <SfToast>
        <ToastButtons>
            <ToastButton Content="Accept" IsPrimary="true" OnClick="@HandleAcceptClick" />
            <ToastButton Content="Dismiss" OnClick="@HandleDismissClick" />
        </ToastButtons>
    </SfToast>

    Constructors

    ToastButton()

    Declaration
    public ToastButton()

    Properties

    Content

    Gets or sets the text content displayed on the toast button.

    Declaration
    [Parameter]
    public string Content { get; set; }
    Property Value
    Type Description
    string

    A string representing the button's text content. The default value is null.

    Remarks

    This property defines the visible text label displayed on the button within the toast notification. If not specified, the button may appear without text content. The content can include plain text or may be combined with icons using the IconCss property.

    CssClass

    Gets or sets the CSS class or multiple classes separated by spaces for styling the toast button.

    Declaration
    [Parameter]
    public string CssClass { get; set; }
    Property Value
    Type Description
    string

    A string containing one or more CSS class names separated by spaces. The default value is null.

    Remarks

    This property allows custom styling of the toast button by applying CSS classes. Multiple classes can be specified by separating them with spaces. These classes are applied to the button element in addition to the default Syncfusion styling classes.

    Disabled

    Gets or sets a value indicating whether the toast button is disabled and cannot be interacted with.

    Declaration
    [Parameter]
    public bool Disabled { get; set; }
    Property Value
    Type Description
    bool

    A bool value indicating the disabled state. true if the button is disabled; otherwise, false. The default value is false.

    Remarks

    When set to true, the button becomes non-interactive, preventing user clicks and other interactions. Disabled buttons typically have a different visual appearance to indicate their non-interactive state. This property is useful for conditional button states based on application logic or user permissions.

    EnableRtl

    Gets or sets a value indicating whether the toast button should be rendered in right-to-left (RTL) direction.

    Declaration
    [Parameter]
    public bool EnableRtl { get; set; }
    Property Value
    Type Description
    bool

    A bool value indicating the RTL rendering mode. true to enable RTL rendering; otherwise, false. The default value is false.

    Remarks

    This property enables right-to-left text direction and layout for the toast button, which is essential for supporting languages such as Arabic, Hebrew, and Persian. When enabled, the button's content and layout elements are mirrored to provide appropriate RTL user experience.

    IconCss

    Gets or sets the CSS class or multiple classes for displaying an icon on the toast button.

    Declaration
    [Parameter]
    public string IconCss { get; set; }
    Property Value
    Type Description
    string

    A string containing CSS class names separated by spaces for icon styling. The default value is null.

    Remarks

    This property specifies the CSS classes used to display an icon on the button. Common icon libraries such as Font Awesome, Bootstrap Icons, or Syncfusion's built-in icons can be used. The icon position relative to the button text is controlled by the IconPosition property.

    IconPosition

    Gets or sets the position of the icon relative to the button text content.

    Declaration
    [Parameter]
    public IconPosition IconPosition { get; set; }
    Property Value
    Type Description
    IconPosition

    An IconPosition enumeration value specifying the icon position. The default value is Left.

    Remarks

    This property determines where the icon appears in relation to the button's text content:

    • Left: The icon is positioned to the left of the text content.
    • Right: The icon is positioned to the right of the text content.
    The icon is specified using the IconCss property and must be defined for this positioning to take effect.

    IsPrimary

    Gets or sets a value indicating whether the toast button should be styled as a primary button.

    Declaration
    [Parameter]
    public bool IsPrimary { get; set; }
    Property Value
    Type Description
    bool

    A bool value indicating the primary button state. true for primary styling; otherwise, false. The default value is false.

    Remarks

    When set to true, the button receives enhanced visual styling that makes it more prominent and appealing compared to regular buttons. Primary buttons typically use accent colors and are used to highlight the most important action available to the user within the toast notification.

    IsToggle

    Gets or sets a value indicating whether the toast button behaves as a toggle button.

    Declaration
    [Parameter]
    public bool IsToggle { get; set; }
    Property Value
    Type Description
    bool

    A bool value indicating the toggle behavior. true to enable toggle functionality; otherwise, false. The default value is false.

    Remarks

    When set to true, the button behaves as a toggle control, switching between normal and active states with each click. Toggle buttons maintain their pressed/active state until clicked again, providing visual feedback about their current state. This is useful for buttons that represent on/off or selected/unselected states.

    OnClick

    Gets or sets the event callback that is invoked when the toast action button is clicked.

    Declaration
    [Parameter]
    public EventCallback<MouseEventArgs> OnClick { get; set; }
    Property Value
    Type Description
    EventCallback<MouseEventArgs>

    An EventCallback<TValue> of type MouseEventArgs that represents the click event handler.

    Remarks

    This event callback is triggered when the user clicks the toast button. The callback receives MouseEventArgs containing information about the mouse event that triggered the click. Use this event to handle button actions such as confirming operations, dismissing the toast, or performing custom business logic.

    Type

    Gets or sets the HTML button type for the toast button element.

    Declaration
    [Parameter]
    public ButtonType Type { get; set; }
    Property Value
    Type Description
    ButtonType

    A ButtonType enumeration value specifying the button type. The default value is Button.

    Remarks

    This property determines the HTML button type attribute, which affects the button's behavior in forms:

    • Button: A regular button with no default form behavior.
    • Submit: Submits the form when clicked.
    • Reset: Resets form fields to their default values when clicked.
    The button type affects how the browser handles the button interaction within form contexts.

    Methods

    Dispose()

    Releases all resources used by the ToastButton component.

    Declaration
    public virtual void Dispose()
    Remarks

    This method implements the IDisposable pattern to ensure proper cleanup of resources. It calls the protected Dispose(bool) method with true to indicate that the method is being called directly from user code rather than from the finalizer.

    Dispose(bool)

    Releases the unmanaged resources used by the ToastButton and optionally releases the managed resources.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    true to release both managed and unmanaged resources; false to release only unmanaged resources.

    Overrides
    OwningComponentBase.Dispose(bool)
    Remarks

    This method implements the dispose pattern for the component. When disposing is true, the method removes this button instance from the parent ToastButtons component's collection and clears the parent reference to prevent memory leaks. The method calls the base class dispose method to ensure proper cleanup of inherited resources.

    OnInitializedAsync()

    Method invoked when the component is ready to start, typically after the component has been initialized.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type Description
    Task

    A Task representing the asynchronous operation.

    Overrides
    ComponentBase.OnInitializedAsync()
    Remarks

    This method is called once during the component's lifecycle, after the component has been constructed and its initial parameters have been set. It registers this button instance with its parent ToastButtons component to be included in the toast's button collection.

    Implements

    IComponent
    IHandleEvent
    IHandleAfterRender
    IDisposable
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved