I really like how this is done in Intellij. They have a toolbar in the right top corner of the markdown area with an Iconbutton for all three options: "Editor only", "Editor and Preview", "Preview only". The toolbar is also only visible when the cursor in positioned inside the markdown area.

image