alexa
menu

Blazor Toolkit

    Show / Hide Table of Contents

    Class SfRadioButton<TChecked>

    Represents a RadioButton component, which is a graphical interface element that allows users to select a single option from a group. It supports checked and unchecked states for user interaction and custom logic.

    Inheritance
    System.Object
    SfBaseComponent
    SfSelectionBase<TChecked>
    SfRadioButton<TChecked>
    Implements
    System.IAsyncDisposable
    Inherited Members
    SfBaseComponent.DisposeAsync()
    SfSelectionBase<TChecked>.Checked
    SfSelectionBase<TChecked>.Created
    SfSelectionBase<TChecked>.CssClass
    SfSelectionBase<TChecked>.Disabled
    SfSelectionBase<TChecked>.EnablePersistence
    SfSelectionBase<TChecked>.HasOnChangeEvent
    SfSelectionBase<TChecked>.InitRender(Boolean)
    SfSelectionBase<TChecked>.Name
    SfSelectionBase<TChecked>.OnAfterRenderAsync(Boolean)
    SfSelectionBase<TChecked>.OnInitializedAsync()
    SfSelectionBase<TChecked>.OnParametersSetAsync()
    SfSelectionBase<TChecked>.SetLocalStorageAsync(String, TChecked)
    SfSelectionBase<TChecked>.UpdateCheckStateAsync(TChecked)
    SfSelectionBase<TChecked>.Value
    Syncfusion.Blazor.Toolkit.Inputs.SfSelectionBase<TChecked>.CheckedChanged
    Syncfusion.Blazor.Toolkit.Inputs.SfSelectionBase<TChecked>.CheckedExpression
    Syncfusion.Blazor.Toolkit.Inputs.SfSelectionBase<TChecked>.ChildContent
    Syncfusion.Blazor.Toolkit.Inputs.SfSelectionBase<TChecked>.HtmlAttributes
    Namespace: Syncfusion.Blazor.Toolkit.Inputs
    Assembly: Syncfusion.Blazor.Toolkit.dll
    Syntax
    public class SfRadioButton<TChecked> : SfSelectionBase<TChecked>, IAsyncDisposable
    Type Parameters
    Name
    TChecked
    Remarks

    This generic component allows flexible data binding to various types for checked state tracking. The RadioButton supports RTL, persistence, label positioning, and can be easily customized via its component parameters. This class should be used when you want to offer a mutually exclusive choice selection within a UI form or group.

    Examples

    The following example demonstrates how to initialize a basic radio button using the Checked property.

    <SfRadioButton Checked="true">
    </SfRadioButton>

    Constructors

    SfRadioButton()

    Declaration
    public SfRadioButton()

    Properties

    Label

    Gets or sets the text label shown next to the radio button.

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

    A System.String that represents the radio button's label text. The default is null.

    Remarks

    The Label property provides simple text content displayed adjacent to the radio input. For accessibility and localization, prefer providing meaningful labels that describe the option conveyed by the radio button.

    The label text is rendered as plain text and is automatically HTML-encoded by Blazor, preventing XSS (Cross-Site Scripting) attacks.

    Examples

    The following examples show how to set the label for a radio button:

    <!-- Simple label -->
    <SfRadioButton Label="Option A" />
    
    <!-- Label with data binding -->
    <SfRadioButton Label="@optionLabel" />

    LabelPosition

    Gets or sets the position of the label relative to the radio input element.

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

    A LabelPosition enumeration value indicating whether the label appears before (left) or after (right) the radio input. The default is Before.

    Remarks

    Changing the LabelPosition adjusts the visual ordering of the label and input which can improve readability in different locales and when supporting RTL layouts.

    Examples
    <!-- Label shown after the radio input -->
    <SfRadioButton Label="Option" LabelPosition="LabelPosition.After" />

    Logger

    Gets the logger instance used for recording component errors.

    Declaration
    public ILogger<SfRadioButton<TChecked>> Logger { get; set; }
    Property Value
    Type
    Microsoft.Extensions.Logging.ILogger<SfRadioButton<TChecked>>

    ValueChange

    Gets or sets a callback invoked when the radio button's value changes due to user interaction.

    Declaration
    public EventCallback<ChangeArgs<TChecked>> ValueChange { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ChangeArgs<TChecked>>

    An Microsoft.AspNetCore.Components.EventCallback<> of type ChangeArgs<TChecked> that is invoked when the checked state changes because of user action. The callback receives a ChangeArgs<TChecked> instance containing the new value and the original event data.

    Remarks

    The ValueChange event is raised only for user-initiated changes (for example, clicks). It is suitable for reacting to user selection, updating other UI state, or performing validation. Programmatically setting the Checked property from code does not automatically trigger this event.

    When handling the callback, prefer using the provided ChangeArgs<TChecked> to access both the value and the originating event payload.

    Examples

    The following example demonstrates registering a handler for the ValueChange event:

    <SfRadioButton ValueChange="OnRadioChanged" />
    
    @code {
        private void OnRadioChanged(ChangeArgs<string> args)
        {
            // React to the new value: args.Value
        }
    }

    Methods

    BuildRenderTree(RenderTreeBuilder)

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

    Implements

    System.IAsyncDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved