Basic Toggle Switch

Disabled
On
<PrimerToggleSwitch @bind-Value="toggle1"
                    Label="Dark Mode"
                    StatusOnText="Enabled"
                    StatusOffText="Disabled"
                    ShowStatusText="true" />

<PrimerToggleSwitch @bind-Value="toggle2"
                    Label="Compact Mode"
                    Size="ToggleSwitchSize.Small"
                    ShowStatusText="true" />

ToggleSwitch Options

Available options for ToggleSwitch component

NameDescriptionDefault ValueCSS Class
Value
Bound boolean value
false
-
Label
Label displayed next to the switch
"Label"
-
ShowStatusText
Whether to show status text (on/off)
true
-
StatusOnText
Text when the switch is ON
"On"
-
StatusOffText
Text when the switch is OFF
"Off"
-
Size
Switch size (Medium, Small)
Medium
-
private bool toggle1 = false;
private bool toggle2 = true;