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.
Inherited Members
Namespace: Syncfusion.Blazor.Buttons
Assembly: Syncfusion.Blazor.dll
Syntax
public class SfRadioButton<TChecked> : SfInputBase<TChecked>
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 label displayed next to the radio button.
Declaration
public string Label { get; set; }
Property Value
Type | Description |
---|---|
System.String | A |
Remarks
Use this property to assign custom text to the radio button's label, allowing users to distinguish between radio button options. Leaving this value empty will hide the label from the rendered output.
LabelPosition
Gets or sets the position of the label in relation to the radio button.
Declaration
public LabelPosition LabelPosition { get; set; }
Property Value
Type | Description |
---|---|
LabelPosition | One of the LabelPosition enumeration values. The default is Before. |
Remarks
If the LabelPosition is Before, the label appears to the left of the radio button. If set to After, the label appears to the right of the radio button. This property helps control the element flow for better localization and accessibility.
ValueChange
Gets or sets an event callback that is invoked when the state of the radio button 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<> that is triggered when the state of the radio button is changed by the user. The callback receives a ChangeArgs<TChecked> argument. |
Remarks
This event is raised only in response to user-based click actions on the radio button. You can use it to perform custom logic or UI updates whenever the checked state is modified by end-users.
Examples
The following example shows how to use the ValueChange
event for the radio button:
<SfRadioButton ValueChange="@Changed">
</SfRadioButton>
@code {
private void Changed(ChangeArgs<TChecked> args)
{
// Custom handler code goes here.
}
}
Methods
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder | __builder |
InitRender(Boolean)
Declaration
protected override void InitRender(bool isDynamic = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isDynamic |
Overrides
OnAfterRenderAsync(Boolean)
Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | firstRender |
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
OnInitializedAsync()
Declaration
protected override Task OnInitializedAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
OnParametersSetAsync()
Declaration
protected override Task OnParametersSetAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |