You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改Mermaid状态图中Transition标签的字体粗细与字号?

可以修改状态图中过渡文本的字体样式

当然可以修改“Transition”字样的字体粗细和字号,你只需要在themeCSS中针对对应过渡边的文本元素添加样式规则即可。

修改后的完整代码如下:

---
config:
  themeCSS: |
    #edge0, #edge1, #edge2 { stroke: red; stroke-width: 2px; }
    #edge1 text { 
        font-weight: bold; 
        font-size: 16px; 
        fill: #333; /* 可选:修改文本颜色 */
    }
---

stateDiagram
direction TB

MainMenu: Main Menu
MainMenu_State_1: First State
MainMenu_State_2: Second State


classDef state fill:#D8BFD8,color:#000000,font-weight:bold, font-size:14px,stroke-width:2px,stroke:#800080

state MainMenu {
    [*] --> MainMenu_State_1
    MainMenu_State_1 --> MainMenu_State_2: Transition
    MainMenu_State_2 --> [*] 
}

class MainMenu_State_1, MainMenu_State_2 state

关键说明:

  • #edge1 对应标注为“Transition”的那条过渡边(可通过开发者工具查看元素ID确认)
  • 通过#edge1 text 选择器定位到这条边上的文本标签,直接设置font-weight和font-size属性
  • 如果要调整其他过渡文本的样式,找到对应边的ID(如#edge0、#edge2),添加类似的text样式规则即可

内容的提问来源于stack exchange,提问作者tueftla

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 17:42:02