AstrolUI AstrolUI
Yellow Orange Red Green Blue Purple Custom color
Light mode
Toggle

1. Demo AstrolToggle


@using Astrol.Component.Basic.Form
 
<label for="toggle-login">Remember me (@(value ? "Yes" : "No"))</label>
<AstrolToggle Id="toggle-login" @bind-Value="value" />
 
<label for="toggle-disabled">Disable</label>
<AstrolToggle Id="toggle-disabled" Value="true" Disable="true" />
@code {
   private bool value = true;
}

Supported parameters

  • Value (bool) / ValueChanged, switch state (default false); supports @bind-Value.
  • OnChange (EventCallback<bool>), raised when the state changes, with the new value.
  • Object (object), associated object returned in OnChangeObject (useful in lists or grids).
  • OnChangeObject (EventCallback<(object?, bool)>), raised when the state changes, with the associated object and the new value.
  • Disable (bool), disables the switch (default false).
  • Id (string), HTML id of the button; lets you link a <label for="...">.
  • LabelledBy (string), id of the element that gives it its accessible name (aria-labelledby).
  • It renders as a <button role="switch">: it is activated by click, Space or Enter. Always give it an accessible name with a label (Id) or with LabelledBy.
Markdown for AI © 2026 AstrolUI v10.0.13