Implementing Toggle Toggles

A toggle is a switch that can be either on or off. Toggles are often used for software settings, but they can also be found in hardware like the caps lock or num lock keys on a keyboard. In software, toggles are often used in options menus to enable or disable features for specific groups of users. Toggle is also a verb, meaning to move back and forth between different states, such as switching screens when video chatting with two friends at once.

Using toggles for setting preferences, settings and other types of information is an effective way to deliver a consistent user experience while providing flexibility. However, there are some important things to keep in mind when using toggles. Make sure the toggles are clearly labeled, use standard visual design, and deliver immediate results to avoid confusion.

In addition, make sure to use the right markup when implementing toggles. It might be tempting to mark up a toggle with a checkbox> element, but that isn’t always the best option. Adrian Roselli has written a great article about the differences between checkboxes and toggles, which might help you determine the best markup for your toggles.

When implementing toggles it’s important to test the configuration that will ultimately go live in production. This includes all toggles that are expected to be flipped On as well as any that you plan to remove. Some teams go even further and include a fallback toggle configuration in their tests so they can identify any regressions that might occur as a result of removing a toggle.

It’s also important to keep in mind that Release Toggles are transitionary by nature and should generally not stick around for more than a few weeks at the most. Savvy teams treat them as inventory which comes with a carrying cost and seek to minimize the number of toggles in their codebase. This can mean adding tasks to the team’s backlog to remove toggles as they are rolled out or creating “expiration dates” for the toggles so that they automatically fail tests when they’re set to expire.

For long-lived toggles (such as Permission Toggles) it’s often best to store the configuration in some type of centralized location, such as an existing application DB. This makes it possible to modify the configuration on a per-request basis without having to restart the process or manually re-deploy the artifact.

In addition to this, many teams choose to implement some sort of admin UI in their environments that allows them to manage the toggle configuration. This UI can range from something as simple as commenting in source code through to more sophisticated approaches that offer dynamic in-memory re-configuration of the toggle. This can be particularly useful when testing for Champagne Brunch or other long-lived Feature Toggles that will be in place for multiple years.