menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfButton - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfButton

    Button is a graphical user interface that helps to triggers an event on its click action. It can contain a text, an icon, svg or both.

    Inheritance
    System.Object
    SfBaseComponent
    SfButton
    SfFab
    Inherited Members
    SfBaseComponent.Dispose()
    SfBaseComponent.Dispose(Boolean)
    SfBaseComponent.OnInitializedAsync()
    SfBaseComponent.OnObservableChange(String, Object, Boolean, NotifyCollectionChangedEventArgs)
    Namespace: Syncfusion.Blazor.Buttons
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class SfButton : SfBaseComponent
    Remarks

    Button content is either by specifying Content property or by specifying content within SfButton tag directive.

    Examples

    In the below code example, a basic button is initialized with Content property.

     
    <SfButton Content="Click"> 
    </SfButton> 

    Constructors

    SfButton()

    Declaration
    public SfButton()

    Properties

    ChildContent

    Gets or sets a value that indicates the child content for the Button including HTML element. If the child content is not specified, button is rendered using Content property.

    Declaration
    public RenderFragment ChildContent { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.RenderFragment

    The template content. The default value is null.

    Remarks

    The child content which is specified within SfButton tag directive is either a string or HTML Element. The string content is also specified using Content property.

    Content

    Gets or sets a value that indicates the content of Button component.

    Declaration
    public string Content { get; set; }
    Property Value
    Type Description
    System.String

    Accepts a string value. The default value is String.Empty.

    Remarks

    Set child content within SfButton tag directive, to render as HTML content.

    Created

    Gets or sets an event callback that is raised when the SfButton rendering is completed.

    Declaration
    public EventCallback<object> Created { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An event callback function.

    CssClass

    Gets or sets a value that indicates the CSS class string to customize the appearance of button.

    Declaration
    public string CssClass { get; set; }
    Property Value
    Type Description
    System.String

    Accepts a CSS class string separated by space to customize the appearance of button. The default value is String.Empty.

    Disabled

    Gets or sets a value that indicates whether to enable or disable the button.

    Declaration
    public bool Disabled { get; set; }
    Property Value
    Type Description
    System.Boolean

    true, if the button component is disabled. The default value is false.

    EnableRtl

    Gets or sets a value that indicates whether to enable or disable the right to left direction for button.

    Declaration
    public bool EnableRtl { get; set; }
    Property Value
    Type Description
    System.Boolean

    true, if the right to left direction is enabled for button. The default value is false.

    IconCss

    Gets or sets a value that indicates the CSS class string to include an icon or image for the button.

    Declaration
    public string IconCss { get; set; }
    Property Value
    Type Description
    System.String

    Accepts a CSS class string separated by space to include an icon or image for the button. The default value is String.Empty.

    IconPosition

    Gets or sets a value that indicates how to display icons in the button.

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

    One of the IconPosition enumeration. The default value is Left

    Remarks

    If the IconPosition is Left, the icon will be placed left to the content of the button. If the IconPosition is Right, the icon will be placed right to the content of the button. If the IconPosition is Top, the icon will be placed above the content of the button. If the IconPosition is Bottom, the icon will be placed below the content of the button.

    IsPrimary

    Gets or sets a value that indicates whether to enable or disable the primary style for button.

    Declaration
    public virtual bool IsPrimary { get; set; }
    Property Value
    Type Description
    System.Boolean

    true, if the primary style is enabled for button component. The default value is false.

    IsToggle

    Gets or sets a value that indicates whether to enable or disable the toggle option for button component.

    Declaration
    public bool IsToggle { get; set; }
    Property Value
    Type Description
    System.Boolean

    true, if the toggle option is enabled for button component. The default value is false.

    OnClick

    Gets or sets an event callback that is raised when the SfButton is clicked.

    Declaration
    public EventCallback<MouseEventArgs> OnClick { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<Microsoft.AspNetCore.Components.Web.MouseEventArgs>

    An event callback function.

    Remarks

    The event is raised for UI based click only.

    Examples
     
    <SfButton OnClick="@Clicked"> 
    </SfButton> 
    @code { 
        private void Clicked(MouseEventArgs args) { 
            // Write your code here. 
        } 
    } 

    Methods

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    FocusAsync()

    focuses the button to perform click action.

    Declaration
    public Task FocusAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    System.Threading.Tasks.Task.

    OnAfterRenderAsync(Boolean)

    Declaration
    protected override Task OnAfterRenderAsync(bool firstRender)
    Parameters
    Type Name Description
    System.Boolean firstRender
    Returns
    Type
    System.Threading.Tasks.Task
    Overrides
    SfBaseComponent.OnAfterRenderAsync(Boolean)

    OnParametersSetAsync()

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type
    System.Threading.Tasks.Task
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved