When a sequence diagram has many messages it gets messy. Dividers / Groups / Boxes let you visually containerize related messages. PlantUML uses group and so does Mermaid — the syntax is nearly identical but the details differ.
sequenceDiagram participant C as Client participant A as Auth Service participant G as API Gateway
group 认证阶段 C->>A: 登录请求 A->>A: 验证凭证 A-->>C: JWT Token end
group 业务请求 C->>G: 请求 + JWT G->>G: 校验 Token G-->>C: 业务数据 end
对比 / Side-by-side
Feature
PlantUML
Mermaid
Keyword
group <label>
group <label>
End marker
end
end
Nesting
Yes, multi-level
Yes
Styling
skinparam groupBackgroundColor
CSS / theme override
Label
Single line, right after group
Same as PlantUML
Arrow style
-> / -->
->> / -->>
小结 / Wrap-up
PlantUML and Mermaid share nearly identical group syntax, so the learning curve is minimal. PlantUML lets you deeply customize colors and borders via skinparam; Mermaid currently relies more on CSS themes. For quick small diagrams Mermaid wins; when you need fine-grained styling go with PlantUML.
Title: Sequence diagrams: grouping with divider/box