69

I cannot find how to insert a line break in long titles inside nodes. For example:

library(DiagrammeR) 
mermaid("
graph TB
     A[GE Solution]-->C{ }
     B[GA Solution]-->C{ } 
     C{ }-->D[Stir 10 mins at 500 r/min]
     D[Stir 10 mins at 500 r/min]-->E[Homogenisation at 10000 r/min]
     E[Homogenisation at 10000 r/min]-->F(Stir 10 min 450 r/min Complex coacervation)
      ")

Note node F is too long. How to I make it into sth like..?

|Stir 10 min 450 r/min|
|Complex coacervation |

Note \n doesn't work.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
Scientist
  • 1,061
  • 2
  • 13
  • 30

2 Answers2

109

It appears you can use <br> instead:

mermaid("
graph TB
        A[GE Solution]-->C{ }
        B[GA Solution]-->C{ } 
        C{ }-->D[Stir 10 mins at 500 r/min]
        D[Stir 10 mins at 500 r/min]-->E[Homogenisation at 10000 r/min]
        E[Homogenisation at 10000 r/min]-->F(Stir 10 min 450 r/min <br> Complex  coacervation)
        ")

enter image description here

Alexander Pozdneev
  • 1,289
  • 1
  • 13
  • 31
Hack-R
  • 22,422
  • 14
  • 75
  • 131
7

Another answer that appears to work just fine is to use \n rather than <br>.

Vorticity
  • 4,582
  • 4
  • 32
  • 49
  • 3
    It doesn't work. Either present an example as how you are using it or share a link explaining your answer in detail. – samar taj Shaikh Dec 28 '22 at 10:57
  • `\n` does not work at `participant` in flowcharts. `
    ` works though.
    – koppor Feb 16 '23 at 08:52
  • I am using Mermaid via [Markdown Viewer](https://chrome.google.com/webstore/detail/markdown-viewer/ckkdlimhmcjmikdlpkmbgfkaikojcbjk) (a Chrome Extension), neither work to produce line break. But it works when I push it to GitHub. Perhaps in my case is implementation in the extension. – dudung Mar 26 '23 at 12:00