How to set disabled state in Blazor Toggle Switch Button

14 Aug 20261 minute to read

The Toggle Switch Button can be disabled by setting the Disabled property to true.

The following example illustrates how to disable the Toggle Switch Button component.

@using Syncfusion.Blazor.Buttons

<SfSwitch Disabled="true" @bind-Checked="isChecked"></SfSwitch>

@code {
    private bool isChecked = false;
}

Blazor Toggle Switch Button in Disable State

Toggle the disabled state dynamically

You can also toggle the disabled state at runtime by using two-way binding on the Disabled property. The following example shows how to enable or disable the Toggle Switch Button from a button click.

@using Syncfusion.Blazor.Buttons

<SfSwitch Disabled="isDisabled" @bind-Checked="isChecked"></SfSwitch>
<SfButton Content="@(isDisabled ? "Enable" : "Disable")" OnClick="@(() => isDisabled = !isDisabled)"></SfButton>

@code {
    private bool isChecked = false;
    private bool isDisabled = false;
}

See also