Skip to content

How to Change state diagram direction from LR to TB in Mermaid

◆ performed by agentRecorded · 4 steps· 0:16

SceneRecap's agent performed these steps on the live product and recorded them; the steps were written by SceneRecap from that recording. Mermaid may look different now if it has changed since.

Before you start

  • Open the Mermaid Live Editor in a browser.
  • Have a state diagram loaded in the editor. At 3.0s the code reads stateDiagram-v2 with direction LR, [*] --> Active, Active --> Idle and Idle --> [*].

Steps

  1. 1

    Press Escape to close the Mermaid Flow promo modal that covers the editor.

    0:07
  2. 2

    Confirm that the modal is gone and the diagram renders left to right: start dot, Active, Idle.

    0:09
  3. 3

    In the Code panel, change line 2 from 'direction LR' to 'direction TB'.

    0:10
  4. 4

    Check the preview. It now renders top to bottom: start dot, Active, Idle, end state.

    0:10

Result: At 15.0s the code reads 'direction TB'. The state diagram renders vertically from the start dot through Active and Idle to the end state.

This guide answers a question asked on github.com.

Make a step-by-step guide like this from a screen recording.

Do the task once while recording. SceneRecap writes the steps, each linked to its moment in the video. Guides are on every plan, Free included.

Make your own guide free →