What is a Toggle?

January 20, 2024 by No Comments

Togle

A toggle is a lever or switch that allows you to control a function. It can be used in a variety of ways to switch between different settings or programs. The word toggle is also used figuratively to describe a process of switching back and forth, as in “he’s toggling between his French and Spanish homework”.

In UI terms, the Toggle is a checkbox-style control that lets you select whether an option should be enabled or disabled. Toggle controls can be grouped into Toggle Groups to enable or disable multiple options at once. A Toggle control has a few different properties that determine how it behaves and what information is displayed to the user when the toggle is clicked.

The name of the Toggle (which is displayed in the tooltip) – optionally followed by a description (which is displayed when the toggle is clicked). The current state of the Toggle – either ‘On’ or ‘Off’. A handler that is called when the Toggle is clicked. This can be any type of handler, including a callback for a webhook or an API request.

Savvy teams view the Feature Toggle inventory in their codebase as something that comes with a carrying cost and strive to keep this inventory as low as possible. This means testing only the toggle configurations which are expected to be live in production plus ensuring that any release toggles are flipped ‘On’. Some teams even go as far as to put ‘expiration dates’ on their toggles and will fail an automated test (or perhaps refuse to run the entire application!) if a toggle is still active after its expiration date.