Class SfSwitch<TChecked>
Switch is a graphical user interface element that allows you to toggle between checked and unchecked state. It has checked and unchecked states.
Inherited Members
Syncfusion.Blazor.Buttons.SfInputBase<TChecked>.CheckedChanged
Syncfusion.Blazor.Buttons.SfInputBase<TChecked>.CheckedExpression
Syncfusion.Blazor.Buttons.SfInputBase<TChecked>.ChildContent
Syncfusion.Blazor.Buttons.SfInputBase<TChecked>.HtmlAttributes
Namespace: Syncfusion.Blazor.Buttons
Assembly: Syncfusion.Blazor.dll
Syntax
public class SfSwitch<TChecked> : SfInputBase<TChecked>
Type Parameters
Name |
---|
TChecked |
Examples
In the below code example, a basic switch is initialized with Checked
property.
<SfSwitch Checked="true">
</SfSwitch>
Constructors
SfSwitch()
Declaration
public SfSwitch()
Properties
jsRuntime
Declaration
protected IJSRuntime jsRuntime { get; set; }
Property Value
Type |
---|
Microsoft.JSInterop.IJSRuntime |
OffLabel
Gets or sets a value that indicates the label for ON state of Switch component.
Declaration
public string OffLabel { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts a string value. The default value is |
OnLabel
Gets or sets a value that indicates the label for ON state of Switch component.
Declaration
public string OnLabel { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts a string value. The default value is |
ValueChange
Gets or sets an event callback that is raised when the switch state is changed.
Declaration
public EventCallback<ChangeEventArgs<TChecked>> ValueChange { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<ChangeEventArgs<TChecked>> | An event callback function. |
Remarks
The event is raised for UI based click only.
Examples
<SfSwitch ValueChange="@Changed">
</SfSwitch>
@code {
private void Changed(ChangeEventArgs<TChecked> 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 |
InitRender()
Declaration
protected override void InitRender()
Overrides
Syncfusion.Blazor.Buttons.SfInputBase<TChecked>.InitRender()
OnAfterRenderAsync(Boolean)
Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | firstRender |
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
Syncfusion.Blazor.Buttons.SfInputBase<TChecked>.OnAfterRenderAsync(System.Boolean)