Class
TelerikSwitch<TValue>

A toggle component for switching between two states (on/off) with labels and theming. Configure width via Width, labels with OnLabel and OffLabel (localized through Switch_OnLabel/Switch_OffLabel), track/thumb roundness using TrackRounded and ThumbRounded, and size through Size. Supports two-way binding through TelerikInputBase{TValue} (Value/ValueChanged), and raises change/blur via the base input events.

Definition

Namespace:Telerik.Blazor.Components

Assembly:Telerik.Blazor.dll

Type Parameters:

TValue

Syntax:

cs-api-definition
public class TelerikSwitch<TValue> : TelerikInputBase<TValue>, IComponent, IHandleEvent, IHandleAfterRender, IDisposable

Inheritance: objectComponentBaseBaseComponentTelerikInputBase<TValue>TelerikSwitch<TValue>

Implements: IComponentIDisposableIHandleAfterRenderIHandleEvent

Inherited Members TelerikInputBase<TValue>.SetParametersAsync(ParameterView)TelerikInputBase<TValue>.OnInitializedAsync()TelerikInputBase<TValue>.OnParametersSetAsync()TelerikInputBase<TValue>.Dispose()TelerikInputBase<TValue>.FocusAsync()TelerikInputBase<TValue>.CascadedEditContextTelerikInputBase<TValue>.FloatingLabelTelerikInputBase<TValue>.IdTelerikInputBase<TValue>.EnabledTelerikInputBase<TValue>.TabIndexTelerikInputBase<TValue>.ValueExpressionTelerikInputBase<TValue>.ValueChangedTelerikInputBase<TValue>.ValueTelerikInputBase<TValue>.OnChangeTelerikInputBase<TValue>.OnBlurTelerikInputBase<TValue>.AriaLabelTelerikInputBase<TValue>.AriaLabelledByTelerikInputBase<TValue>.AriaDescribedByTelerikInputBase<TValue>.ValidateOnTelerikInputBase<TValue>.InputModeBaseComponent.ShouldRender()BaseComponent.OnAfterRenderAsync(bool)BaseComponent.InitLocalizer()BaseComponent.ThrowIfParameterIsNull(object, string)BaseComponent.HaveOptionsChanged(IDictionary<string, object>, IDictionary<string, object>)BaseComponent.GetClassString(params string[])BaseComponent.InvokeAsync<T>(string, params object[])BaseComponent.InvokeAsync<T>(string, CancellationToken, params object[])BaseComponent.InvokeVoidAsync(string, params object[])BaseComponent.InvokeVoidAsyncWithoutAwait(string, params object[])BaseComponent.InvokeComponentMethodAsync<T>(string, params object[])BaseComponent.InvokeComponentMethodAsync<T>(string, CancellationToken, params object[])BaseComponent.InvokeVoidComponentMethodAsync(string, params object[])BaseComponent.InvokeComponentVoidMethodAsync(string, object)BaseComponent.InvokeDisposeAsync()BaseComponent.StateHasChanged()BaseComponent.RootComponentBaseComponent.ClassComponentBase.OnInitialized()ComponentBase.OnParametersSet()ComponentBase.InvokeAsync(Action)ComponentBase.InvokeAsync(Func<Task>)ComponentBase.DispatchExceptionAsync(Exception)

Constructors

TelerikSwitch()

Declaration

cs-api-definition
public TelerikSwitch()

Properties

DataSmartPasteDescriptionAttribute

Gets or sets the description used for the data-smart-paste attribute.

Declaration

cs-api-definition
[Parameter]
public string DataSmartPasteDescriptionAttribute { get; set; }

Property Value

string

EnableWebMcpTools

Enables WebMCP tool registration for this Switch. When true, Switch operations are exposed as tools discoverable by AI models through the browser. Default value is false.

Declaration

cs-api-definition
[Parameter]
public bool EnableWebMcpTools { get; set; }

Property Value

bool

OffLabel

Defines the off label of the switch. If not set, its value is set through the localizaiton Switch_OffLabel, or "Off" if there is no localization.

Declaration

cs-api-definition
[Parameter]
public string OffLabel { get; set; }

Property Value

string

OnLabel

Defines the on label of the switch. If not set, its value is set through the localizaiton Switch_OnLabel, or "On" if there is no localization.

Declaration

cs-api-definition
[Parameter]
public string OnLabel { get; set; }

Property Value

string

Size

Defines the size of the switch.

Declaration

cs-api-definition
[Parameter]
public string Size { get; set; }

Property Value

string

SwitchSettings

Provides configuration for WebMCP tools, such as a Name to distinguish this Switch from others on the same page.

Declaration

cs-api-definition
[Parameter]
public RenderFragment SwitchSettings { get; set; }

Property Value

RenderFragment

ThumbRounded

Defines the roundness of the switch thumb. The default value is Full.

Declaration

cs-api-definition
[Parameter]
public string ThumbRounded { get; set; }

Property Value

string

TrackRounded

Defines the roundness of the switch track. The default value is Full.

Declaration

cs-api-definition
[Parameter]
public string TrackRounded { get; set; }

Property Value

string

Width

Defines the width of the Component as a CSS value.

Declaration

cs-api-definition
[Parameter]
public string Width { get; set; }

Property Value

string

Methods

BuildRenderTree(RenderTreeBuilder)

Declaration

cs-api-definition
protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder

RenderTreeBuilder

Overrides ComponentBase.BuildRenderTree(RenderTreeBuilder)

OnAfterRender(bool)

Declaration

cs-api-definition
protected override void OnAfterRender(bool firstRender)

Parameters

firstRender

bool

Overrides ComponentBase.OnAfterRender(bool)