Skip to main content

Switch

Switches or Toggles are a special type of input widget that can be used to switch between two states. They are commonly used in forms to toggle between different options or settings. Toggles can be used as an input element or as a button element.

Design Hints
Toggles are a great way to provide users with a quick and easy way to switch between different options or settings. They are also a good way to save space on a form and make it more visually appealing.
Accessiblity Hints
For accessibility, it is important to ensure that the toggles are keyboard accessible. ravixUI uses an input type checkbox with role switch and labels to make the toggles accessible. While sr-only text has been added to the labels, in most cases you would use a visible label to describe the toggle.

Simple Switch

A simple switch input to toggle between two states.

Alternate Simple Switch

An alternate style for simple switches.

Accessibility Testing Status

ComponentNVDAWindows NarratorWAVEAxeIBM Equal Access
Simple SwitchYesYesYesYesPartial*
Alternate Simple SwitchYesYesYesYesPartial*

*The IBM Equal Access Accessibility Checker shows errors for missing aria-checked attribute even though its an input type checkbox with a role switch. If an aria-checked attribute is added, it would be double dipping since input type checkbox already conveys if it is checked or not.

For more information on the implementation of the switches, you can refer to the ARIA Authoring Practices Guide for Switch pattern