sequence-diagramplantuml

Sequence Diagram participant / actor name with newline on PlantUML


How to use a newline in a sequence diagram participant / actor name ? It would be particularly useful when you have a long name like this:

 ┌───┐          ┌─────────────────┐
 │Bob│          │VeryLongAliceName│
 └─┬─┘          └────────┬────────┘
   │       hello         │         
   │────────────────────>│         
 ┌─┴─┐          ┌────────┴────────┐
 │Bob│          │VeryLongAliceName│
 └───┘          └─────────────────┘

I'd like to have it like this:

                ┌─────────┐
 ┌───┐          │VeryLong │
 │Bob│          │AliceName│
 └─┬─┘          └────┬────┘
   │     hello       │     
   │────────────────>│     
 ┌─┴─┐          ┌────┴────┐
 │Bob│          │VeryLong │
 └───┘          │AliceName│
                └─────────┘

Solution

  • Just wrap your participant name in double quotes ", then you can use the newline escape sequence \n to break the name in two lines, like this:

    @startuml
    Bob -> "VeryLong\nAliceName": hello
    @enduml