A toggle switch, when applied to a user interface, represents one of two outcomes (on or off) and is found in nearly every aspect of a computing application that includes an options or preferences list. Toggles are particularly common in software that requires the user to select from multiple choices.
As such a toggle needs to be easy for users to understand. The best way to do this is to provide clear, direct labels and apply standard visual design. In general toggles should be used when the result of a change is immediate and does not require an additional step such as saving or submitting. They also are a good choice for features that have a default value and when a checkbox or radio button is not the appropriate markup.
Color is a critical aspect of the toggle design and it should be selected carefully. Not only is there the heuristic consideration that users need to see that the toggle has changed states, but designers should consider the societal and cultural implications of using certain colors as they might not be understood in all environments.
In terms of UI, it is worth mentioning that some research suggests that users view a darker, more saturated color as being the active option while a lighter color may be viewed as inactive. This is likely due to the fact that it takes less cognitive effort for a human to process a more saturated color.