A toggle is a control that has two states: on and off. It is the best choice for changing the settings of a system.
Almost all options and preferences menus in most applications use toggles. This is a great way to make changes easily because it only requires a user to click a button or press a simple key combination.
Togle Configuration: Managed in static files
Managing toggle configuration is relatively easy but it can become cumbersome and difficult to maintain as the number of toggles grows. In these cases it is common to move toggle configuration out of static files into a centralized store where it can be easily modified by team members.
In this case a UI layer is built to allow system operators, testers and product managers to access toggle configuration and make changes directly. These changes are then pushed into a central configuration store, often an existing application DB.
Static configuration is preferred to dynamic re-configuration for a couple of reasons. One is that static toggles are less likely to change during a release cycle as the toggle decision is baked into each new release. This means that there is less need to verify a release against the toggle configuration in an older version of the flag.
Another reason to prefer static toggle configuration is that it makes the toggling decision for a feature flag much more stable and predictable. This means that if we are using a toggle to perform multivariate testing, or to experiment with different code paths, the toggling decision is always going to be consistent – unlike a Permissioning Toggle where the toggling decision will be based upon a user’s permission level.
The only downside to this approach is that it is very fiddly and can be difficult to ensure that toggle configuration is correct across a fleet of servers. This can be an issue for teams that have very large and complex feature flags with many configuration variables.
Color is an important visual signifier for toggles and should be used to signal the state of the switch. It should be a high-contrast color to avoid confusion. It should also be used to communicate what the state of the toggle is – for example, red is an off position, while yellow is an on position.
A label is a critical component of toggles and should describe the control’s state as well as its option value. Good labels should be clear, short and direct.
A toggle should not require a user to tap the Save or Confirm button. This is because users may forget to tap the button and the control might remain in its previous state, which can confuse the user.