Making Toggle Switches More Accessible
A toggle is a fastener used to keep something in place, such as a pin passed through the eye of a rope to hold it. It can also refer to a switch that has two positions, such as the one on your keyboard that turns the caps lock on or off. The word is also commonly used figuratively to mean switching back and forth, as in toggling between two different tasks or between screens when video chatting with two people at once.
In software, the toggle is a button-like control that is either active or inactive, and it can be clicked to switch between them. It can also be seen in options menus for most applications. Users are able to see the current state of a toggle by its color or other visual cues.
Toggle switches are commonly used in the design of user interfaces (UIs) because they can be more effective than simple checkboxes for indicating that a setting has been changed. However, a variety of factors can make toggles difficult for some users to use. In this article we will discuss some of the reasons why, and then we will show a few techniques for making toggle switches more accessible.
A common approach to managing Feature Toggles is to hardcode them into a codebase using either comments or preprocessor features such as #ifdef. This approach is fine for small number of toggles but becomes cumbersome as the toggle count grows. It is also difficult to test and debug at scale as it requires that the toggle be re-deployed in order to change its configuration.
The other option is to move the toggle configuration into some type of centralized store, often an existing application database. This is often accompanied by some form of admin UI for viewing and modifying the toggle configuration. This is more appropriate at larger scale but still requires that the toggle be re-deployed to change its configuration.
While it is possible to re-deploy a toggle it can be problematic in shared environments as it requires that all testers have the same version of the software in order to exercise and verify that the toggle changes its state. In addition it can negatively impact the cycle time of CI/CD for re-deploying and validating the artifacts in each environment. A better alternative is to expose an endpoint that can dynamically re-configure the toggle in memory, this is known as runtime configuration and is typically supported by most Feature Flag systems.