Toggle is a simple user-interface control that allows users to update preferences and settings. It’s a great way to show or hide content without creating a new page or forcing the user to navigate through a long process. When used well, toggles are simple to understand and offer a consistent experience for the user.
Toggles should always be used sparingly. They are powerful and it’s easy to use them incorrectly and cause confusion. For example, using a toggle to download content is not an appropriate use of a toggle switch. Downloading is a one-time action that ends after the toggle is turned off, whereas a toggle switch is a state that persists.
When a feature is being tested or not in production, it can be hidden behind a toggle. This allows teams to perform the entire development, testing and QA process right on trunk code, without having to wait until that feature is ready for full deployment. This approach is also referred to as canary release.
Toggle configuration is often managed via static files, which are then deployed to all servers. This can get cumbersome at scale, and maintaining consistency across a fleet of servers is a challenge. Additionally, the overhead of modifying these files can have an impact on performance (especially read performance). To alleviate this, many teams move their toggle configuration to some form of centralized store, typically an existing application DB. This can be accompanied by the build out of some form of admin UI which allows system operators, testers and product managers to view and manage feature flags.