Class ToastButton
Provides configuration data for action buttons within the Toast notification component.
Inheritance
Namespace: Syncfusion.Blazor.Notifications
Assembly: Syncfusion.Blazor.dll
Syntax
public class ToastButton : OwningComponentBase
Remarks
The ToastButton class enables customization of buttons displayed in toast notifications, including appearance, behavior, and user interaction handling. This component inherits from Microsoft.AspNetCore.Components.OwningComponentBase 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
public string Content { get; set; }
Property Value
Type | Description |
---|---|
System.String | A |
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
public string CssClass { get; set; }
Property Value
Type | Description |
---|---|
System.String | A |
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
public bool Disabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A |
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
public bool EnableRtl { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A |
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
public string IconCss { get; set; }
Property Value
Type | Description |
---|---|
System.String | A |
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
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:
IsPrimary
Gets or sets a value indicating whether the toast button should be styled as a primary button.
Declaration
public bool IsPrimary { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A |
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
public bool IsToggle { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A |
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
public EventCallback<MouseEventArgs> OnClick { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<Microsoft.AspNetCore.Components.Web.MouseEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> of type Microsoft.AspNetCore.Components.Web.MouseEventArgs that represents the click event handler. |
Remarks
This event callback is triggered when the user clicks the toast button. The callback receives Microsoft.AspNetCore.Components.Web.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
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:
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(Boolean) method with true
to indicate that the
method is being called directly from user code rather than from the finalizer.
Dispose(Boolean)
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 |
---|---|---|
System.Boolean | disposing |
|
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 |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
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.