Switch
Toggle switch for boolean on/off values.
Installation
Add the Switch component using the CLI:
shadcnblazor component add switch
Usage
The Switch component is a toggle for boolean on/off values. Use ChildContent for the label. Bind Checked for two-way state, or use CheckedChanged for one-way updates.
Examples
Sizes
Use the Size parameter for Sm, Md, or Lg variants.
API Reference
Switch
Toggle switch for boolean on/off values.
Properties
| Name | Type | Description |
|---|---|---|
AdditionalAttributes |
Dictionary<string, Object> |
|
Checked |
bool |
Whether the switch is on. |
CheckedChanged |
EventCallback<bool> |
Callback invoked when the checked state changes. |
ChildContent |
RenderFragment |
Content to display alongside the switch (e.g., label). |
Class |
string |
|
Disabled |
bool |
Whether the switch is disabled. |
Size |
Size |
The size of the switch. |
Events
| Name | Type | Description |
|---|---|---|
CheckedChanged |
EventCallback<bool> |
Callback invoked when the checked state changes. |
Methods
| Method | Returns | Description |
|---|---|---|
Equals |
bool |
|
GetHashCode |
int |
|
GetType |
Type |
|
SetParametersAsync |
Task |
|
ToString |
string |
Mobile support for API reference coming soon.