Use a toggle button when there are related views that may be switched between for the same screen or content.
How to use
The action triggered by clicking on a toggle button should occur immediately and on the same page.
Toggle buttons can have text, icons, or both.
Be cautious when using only icons. Consider using visually hidden text for people using screenreaders and other assistive devices. Also consider whether the icons you choose are going to be sufficient to communciate the meaning of the action to an average person.