Toggle is a powerful feature that allows teams to dynamically re-configure specific service instances on demand. However, if used inappropriately it can be extremely confusing for the rest of your team and a nightmare to debug weeks or months down the road. Ideally, you should only use toggles for short-lived experiments or features that will be in production for a very limited set of users (e.g. a Canary Release or Champagne Brunch).
It’s important to keep your inventory of toggles low and prune old ones as soon as they’ve served their purpose. A large number of idle toggles can be a maintenance burden and can introduce bugs or regressions in your codebase. To help avoid this, many teams choose to move their toggle configuration out of static files and into some kind of centralized store, often an existing application DB. They also usually build out a form of admin UI to allow system operators, testers and product managers to view and modify their toggle configuration.
Toggles should be clearly labeled to identify what they affect and their current state. A common way to do this is to add an interface icon that communicates the state of the toggle and update the icon’s appearance based on its current state. This helps ensure that people can quickly understand what the toggle is affecting and why it is in its current state. Using high-contrast colors can also be helpful to make it clear that the toggle is active, especially for users with red/green color blindness or other visual impairments.
In general, when designing a toggle it is best to think of the user experience as the primary concern. If the toggle isn’t obvious or easy to use it won’t get used.
A good rule of thumb is to design your toggles so that one click will turn them on or off. This makes them more accessible and increases the likelihood that your users will engage with them.
While it is tempting to use a toggle for everything from enabling or disabling content to changing the appearance of an article it’s important not to abuse the privilege. If you are going to use a toggle for something as complex as changing the layout of an entire page then it’s probably better to split the article into multiple pages and use a CMS to manage the layout.
It’s important to thoroughly test all toggles that you expect to go live in production, including those with the fallback configuration flipped Off. Additionally, many teams perform some tests with all toggles flipped on to avoid surprise regressions in future releases. However, this is only a sensible approach if you are following the convention of having existing or legacy behavior enabled when a toggle is flipped On and new or future behavior enabled when it’s flipped Off. Otherwise, you could end up with a confusing jumble of toggles that don’t really do anything.