Table of Contents

Class TwSwitch<T>

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

Represents a toggle switch component that allows users to select between two states.

public class TwSwitch<T> : TwBlazorInputComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent, ITwInputComponent

Type Parameters

T
Inheritance
TwSwitch<T>
Implements
Inherited Members

Remarks

Supports two-way data binding through the Value and ValueChanged parameters, enabling parent components to react to changes in the switch's state. The component can be customized with a name and color, and is typically used in forms or settings panels where a binary choice is required.

Constructors

TwSwitch()

public TwSwitch()

Properties

Color

Gets or sets the color of the switch.

[Parameter]
public Color? Color { get; set; }

Property Value

Color?

Name

Gets or sets the name associated with the component.

[Parameter]
public string Name { get; set; }

Property Value

string

Value

Gets or sets the current value of the parameter.

[Parameter]
public T Value { get; set; }

Property Value

T

ValueChanged

Gets or sets the callback that is invoked when the value changes.

[Parameter]
public EventCallback<T> ValueChanged { get; set; }

Property Value

EventCallback<T>

Remarks

Use this property to handle value change events in two-way data binding scenarios. The callback is triggered when the component's value is updated, allowing parent components to respond to the change.

Methods

BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder