Flowcharts: LR / TB / RL / BT directions
简介 / Introduction
Flowcharts are one of the most commonly used diagram types. Both PlantUML and Mermaid let you specify the layout direction with a simple directive: left to right direction (or LR) and top to bottom direction (or TB) are the two most common orientations. This article uses the same example to show both engines’ direction syntax side by side.
PlantUML 版
PlantUML uses @startuml with a separate direction directive (left to right direction or top to bottom direction) placed on its own line after the start tag.
1 | @startuml |
left to right direction arranges nodes from left to right. Change it to top to bottom direction to switch to a vertical top-to-bottom layout.
Mermaid 版
Mermaid encodes the direction directly into the flowchart declaration using a two-letter abbreviation (LR, TB, RL, BT):
1 | flowchart LR |
flowchart LR means left-to-right. Use flowchart TB for top-to-bottom, flowchart RL for right-to-left, and flowchart BT for bottom-to-top.
对比 / Side-by-side
| Feature | PlantUML | Mermaid |
|---|---|---|
| Direction placement | Separate line after @startuml |
Embedded in flowchart keyword |
| Keywords | left to right direction / top to bottom direction |
LR / TB / RL / BT |
| Horizontal layout | left to right direction |
flowchart LR |
| Vertical layout | top to bottom direction |
flowchart TB |
小结 / Wrap-up
Both engines make direction intuitive: PlantUML uses a more verbose natural-language directive, while Mermaid encodes the orientation into the diagram type keyword for a more compact syntax. In practice, horizontal layouts (LR/RL) work well on wide screens, while vertical layouts (TB/BT) suit long pages and documents.
- Title: Flowcharts: LR / TB / RL / BT directions
- Author: puml.online
- Created at : 2026-09-12 09:00:00
- Updated at : 2026-09-29 01:06:38
- Link: https://puml.online/blog/flowchart-direction-lr-tb-en/
- License: This work is licensed under CC BY-NC-SA 4.0.