ToggleButton
Button that toggles between two visual states (on/off). Depends on Button.
Installation
Add the ToggleButton component using the CLI:
shadcnblazor component add togglebutton
Usage
A button that toggles between two visual states (on/off). Uses Button internally. Bind IsToggled for two-way state, or use IsToggledChanged for one-way updates. Set VariantUntoggled and VariantToggled for the two states.
Examples
Variants
Use VariantUntoggled and VariantToggled to control the appearance in each state.
API Reference
ToggleButton
A button that toggles between two visual states (on/off).
Properties
| Name | Type | Description |
|---|---|---|
AdditionalAttributes |
Dictionary<string, Object> |
|
ChildContent |
RenderFragment |
The content rendered inside the button. |
Class |
string |
|
Disabled |
bool |
When true, the button is disabled. |
IsToggled |
bool |
Whether the button is currently toggled on. Use with for two-way binding. |
IsToggledChanged |
EventCallback<bool> |
Callback fired when the toggled state changes. Use with for two-way binding. |
OnClick |
EventCallback<MouseEventArgs> |
Callback fired when the button is clicked. |
Size |
Size |
The size of the button. |
Type |
ButtonType |
The HTML button type. |
VariantToggled |
Variant |
The variant when the button is toggled on. |
VariantUntoggled |
Variant |
The variant when the button is not toggled. |
Events
| Name | Type | Description |
|---|---|---|
IsToggledChanged |
EventCallback<bool> |
Callback fired when the toggled state changes. Use with for two-way binding. |
OnClick |
EventCallback<MouseEventArgs> |
Callback fired when the button is clicked. |
Methods
| Method | Returns | Description |
|---|---|---|
Equals |
bool |
|
GetHashCode |
int |
|
GetType |
Type |
|
SetParametersAsync |
Task |
|
ToString |
string |
Mobile support for API reference coming soon.