SwitchField

A toggle switch for boolean on/off values. Visually distinct from a checkbox, the switch uses role="switch" and aria-checked for correct semantics. Use this when the setting takes effect immediately or when the visual metaphor of an on/off toggle is more appropriate than a checkbox.

Basic Usage

<ArcadiaForm Model="model">
    <SwitchField Field="@nameof(Model.DarkMode)" Label="Enable Dark Mode" />
</ArcadiaForm>

Parameters

ParameterTypeDefaultDescription
ValueboolfalseWhether the toggle switch is currently in the on position. Supports two-way binding.
ValueChangedEventCallback<bool>Callback invoked when the user flips the toggle switch.

Inherited from FieldBase

ParameterTypeDefaultDescription
Labelstring?nullVisible label displayed next to the switch.
HelperTextstring?nullHelper text displayed below the switch.
DisabledboolfalseWhether the switch is disabled.
ErrorsIReadOnlyList<string>?nullValidation errors to display.
SchemaFieldSchema?nullField schema definition for dynamic form generation.

Validation

public class NotificationSettings
{
    public bool EmailNotifications { get; set; } = true;
}

Accessibility

  • Uses role="switch" on the underlying checkbox input for correct switch semantics.
  • Reports state via aria-checked="true" or aria-checked="false".
  • Helper text and validation errors are linked via aria-describedby.