GitHub

Switch

On/off toggle control with label, hint, and model binding.

<rhx-switch>

Examples

Basic

Pre-checked

With Hint

Automatically save changes every 30 seconds

Sizes

States

Model Binding

htmx Integration

Receive email alerts for important updates
Toggle the switch...

Properties

Property Type Default Description
rhx-for ModelExpression - ASP.NET Core model expression for two-way binding
name string - The form field name
rhx-label string - Label text displayed next to the switch
rhx-hint string - Hint text displayed below the label
rhx-checked bool false Whether the switch is on
rhx-size string medium Switch size: small, medium, large
rhx-disabled bool false Whether the switch is disabled

Accessibility

  • Uses role="switch" with aria-checked for on/off state.
  • Label is associated for screen readers.
  • Keyboard: Space toggles the switch.
  • Hint text linked via aria-describedby.