excalidraw-design-guide
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExcalidraw Diagram Design Guide
Excalidraw图表设计指南
Color Palette
调色板
Stroke Colors (borders & text)
描边颜色(边框与文本)
| Name | Hex | Use for |
|---|---|---|
| Black | #1e1e1e | Default text & borders |
| Red | #e03131 | Errors, warnings, critical |
| Green | #2f9e44 | Success, approved, healthy |
| Blue | #1971c2 | Primary actions, links |
| Purple | #9c36b5 | Services, middleware |
| Orange | #e8590c | Async, queues, events |
| Cyan | #0c8599 | Data stores, databases |
| Gray | #868e96 | Annotations, secondary |
| 名称 | 十六进制码 | 适用场景 |
|---|---|---|
| 黑色 | #1e1e1e | 默认文本与边框 |
| 红色 | #e03131 | 错误、警告、关键内容 |
| 绿色 | #2f9e44 | 成功、已批准、健康状态 |
| 蓝色 | #1971c2 | 主要操作、链接 |
| 紫色 | #9c36b5 | 服务、中间件 |
| 橙色 | #e8590c | 异步流程、队列、事件 |
| 青色 | #0c8599 | 数据存储、数据库 |
| 灰色 | #868e96 | 注释、次要内容 |
Fill Colors (backgroundColor — pastel)
填充颜色(背景色 — 马卡龙色调)
| Name | Hex | Pairs with stroke |
|---|---|---|
| Light Red | #ffc9c9 | #e03131 |
| Light Green | #b2f2bb | #2f9e44 |
| Light Blue | #a5d8ff | #1971c2 |
| Light Purple | #eebefa | #9c36b5 |
| Light Orange | #ffd8a8 | #e8590c |
| Light Cyan | #99e9f2 | #0c8599 |
| Light Gray | #e9ecef | #868e96 |
| White | #ffffff | #1e1e1e |
| 名称 | 十六进制码 | 搭配描边色 |
|---|---|---|
| 浅红色 | #ffc9c9 | #e03131 |
| 浅绿色 | #b2f2bb | #2f9e44 |
| 浅蓝色 | #a5d8ff | #1971c2 |
| 浅紫色 | #eebefa | #9c36b5 |
| 浅橙色 | #ffd8a8 | #e8590c |
| 浅青色 | #99e9f2 | #0c8599 |
| 浅灰色 | #e9ecef | #868e96 |
| 白色 | #ffffff | #1e1e1e |
Sizing Rules
尺寸规则
- Minimum shape: width >= 120px, height >= 60px
- Shape width formula: — prevents text truncation
max(160, labelTextLength * 9) - Shape height: 60px single-line, 80px two-line, 100px three-line labels
- Font sizes: body text >= 16, titles/headers >= 20, small labels >= 14
- Padding: at least 20px inside shapes for text breathing room
- Arrow length: minimum 80px between connected shapes
- Consistent sizing: same-role shapes = same dimensions
- 最小形状尺寸:宽度 ≥ 120px,高度 ≥ 60px
- 形状宽度计算公式:— 防止文本截断
max(160, labelTextLength * 9) - 形状高度:单行文本60px,两行文本80px,三行文本100px
- 字体大小:正文文本≥16px,标题/表头≥20px,小标签≥14px
- 内边距:形状内部至少保留20px的文本留白
- 箭头长度:相连形状之间的最小距离为80px
- 尺寸一致性:同类型角色的形状需使用相同尺寸
Layout Patterns
布局模式
- Grid snap: align to 20px grid for clean layouts
- Spacing: 40–80px gap between adjacent shapes
- Flow direction: top-to-bottom (vertical) or left-to-right (horizontal)
- Hierarchy: important nodes larger or higher; left-to-right = temporal order
- Grouping: cluster related elements; use background rectangles as zones
- Tier layout:
- Tier 1 (y=50–130): Client apps / entry points
- Tier 2 (y=200–280): Gateway / edge layer
- Tier 3 (y=350–440): Services (spread wide: 160–200px apart)
- Tier 4 (y=510–590): Data stores
- Side panels: x < 0 or x > mainDiagramRight + 80
- 网格对齐:对齐到20px网格以实现整洁布局
- 间距设置:相邻形状之间的间距为40–80px
- 流向:从上到下(垂直)或从左到右(水平)
- 层级结构:重要节点更大或位置更靠前;从左到右代表时间顺序
- 分组:将相关元素聚类;使用背景矩形作为分区
- 分层布局:
- 第一层(y=50–130):客户端应用 / 入口点
- 第二层(y=200–280):网关 / 边缘层
- 第三层(y=350–440):服务(横向分散:间距160–200px)
- 第四层(y=510–590):数据存储
- 侧边面板:x < 0 或 x > 主图表右侧边缘 + 80px
Arrow Best Practices
箭头最佳实践
Binding (always use element IDs, not raw coordinates)
绑定方式(始终使用元素ID,而非原始坐标)
json
{"type": "arrow", "x": 0, "y": 0, "start": {"id": "svc-a"}, "end": {"id": "svc-b"}}Server auto-routes arrows to element edges using precise geometry.
json
{"type": "arrow", "x": 0, "y": 0, "start": {"id": "svc-a"}, "end": {"id": "svc-b"}}服务器会通过精确几何计算自动将箭头路由到元素边缘。
Line styles
线条样式
- Solid: synchronous calls, direct dependencies
- Dashed (): async flows, optional paths, events
"strokeStyle": "dashed" - Dotted (): weak dependencies, annotations
"strokeStyle": "dotted"
- 实线:同步调用、直接依赖
- 虚线 ():异步流程、可选路径、事件
"strokeStyle": "dashed" - 点线 ():弱依赖、注释
"strokeStyle": "dotted"
Arrowheads
箭头头部
- — default directed flow
"endArrowhead": "arrow" - — data stores
"endArrowhead": "dot" - — plain line (undirected)
"endArrowhead": null
- — 默认的有向流
"endArrowhead": "arrow" - — 数据存储
"endArrowhead": "dot" - — 普通线条(无方向)
"endArrowhead": null
Labels on arrows
箭头标签
Use — keep to 1–2 words. Long labels overlap shapes.
"label": {"text": "HTTP"}使用 — 标签控制在1–2个单词内,过长标签会导致形状重叠。
"label": {"text": "HTTP"}Routing complex arrows (avoid crossings)
复杂箭头路由(避免交叉)
Curved arrow (arc over elements):
json
{
"type": "arrow", "x": 100, "y": 100,
"points": [[0,0],[50,-40],[200,0]],
"roundness": {"type": 2},
"strokeColor": "#1971c2"
}Elbowed arrow (L-shape, right-angle routing):
json
{
"type": "arrow", "x": 100, "y": 100,
"points": [[0,0],[0,-50],[200,-50],[200,0]],
"elbowed": true
}弧形箭头(从元素上方绕过):
json
{
"type": "arrow", "x": 100, "y": 100,
"points": [[0,0],[50,-40],[200,0]],
"roundness": {"type": 2},
"strokeColor": "#1971c2"
}直角箭头(L形,直角路由):
json
{
"type": "arrow", "x": 100, "y": 100,
"points": [[0,0],[0,-50],[200,-50],[200,0]],
"elbowed": true
}Diagram Type Templates
图表类型模板
Architecture Diagram
架构图
json
{
"elements": [
{
"id": "zone-backend",
"type": "rectangle",
"x": 40, "y": 40, "width": 600, "height": 400,
"backgroundColor": "#e9ecef", "strokeColor": "#868e96",
"opacity": 40,
"label": {"text": "Backend", "fontSize": 20}
},
{
"id": "api-gw",
"type": "rectangle",
"x": 80, "y": 100, "width": 180, "height": 70,
"strokeColor": "#9c36b5", "backgroundColor": "#eebefa",
"label": {"text": "API Gateway"}
},
{
"id": "auth-svc",
"type": "rectangle",
"x": 80, "y": 240, "width": 180, "height": 70,
"strokeColor": "#1971c2", "backgroundColor": "#a5d8ff",
"label": {"text": "Auth Service"}
},
{
"id": "db",
"type": "rectangle",
"x": 80, "y": 380, "width": 180, "height": 70,
"strokeColor": "#0c8599", "backgroundColor": "#99e9f2",
"label": {"text": "Postgres"}
},
{"type":"arrow","x":0,"y":0,"start":{"id":"api-gw"},"end":{"id":"auth-svc"},"label":{"text":"JWT verify"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"auth-svc"},"end":{"id":"db"},"label":{"text":"SQL"},"strokeStyle":"dashed"}
]
}json
{
"elements": [
{
"id": "zone-backend",
"type": "rectangle",
"x": 40, "y": 40, "width": 600, "height": 400,
"backgroundColor": "#e9ecef", "strokeColor": "#868e96",
"opacity": 40,
"label": {"text": "Backend", "fontSize": 20}
},
{
"id": "api-gw",
"type": "rectangle",
"x": 80, "y": 100, "width": 180, "height": 70,
"strokeColor": "#9c36b5", "backgroundColor": "#eebefa",
"label": {"text": "API Gateway"}
},
{
"id": "auth-svc",
"type": "rectangle",
"x": 80, "y": 240, "width": 180, "height": 70,
"strokeColor": "#1971c2", "backgroundColor": "#a5d8ff",
"label": {"text": "Auth Service"}
},
{
"id": "db",
"type": "rectangle",
"x": 80, "y": 380, "width": 180, "height": 70,
"strokeColor": "#0c8599", "backgroundColor": "#99e9f2",
"label": {"text": "Postgres"}
},
{"type":"arrow","x":0,"y":0,"start":{"id":"api-gw"},"end":{"id":"auth-svc"},"label":{"text":"JWT verify"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"auth-svc"},"end":{"id":"db"},"label":{"text":"SQL"},"strokeStyle":"dashed"}
]
}Flowchart
流程图
json
{
"elements": [
{"id":"start","type":"ellipse","x":160,"y":40,"width":120,"height":60,
"strokeColor":"#2f9e44","backgroundColor":"#b2f2bb","label":{"text":"Start"}},
{"id":"step1","type":"rectangle","x":140,"y":160,"width":160,"height":60,
"strokeColor":"#1971c2","backgroundColor":"#a5d8ff","label":{"text":"Validate Input"}},
{"id":"decide","type":"diamond","x":140,"y":280,"width":160,"height":80,
"strokeColor":"#e8590c","backgroundColor":"#ffd8a8","label":{"text":"Valid?"}},
{"id":"end-ok","type":"ellipse","x":340,"y":290,"width":100,"height":60,
"strokeColor":"#2f9e44","backgroundColor":"#b2f2bb","label":{"text":"Success"}},
{"id":"end-err","type":"ellipse","x":0,"y":290,"width":100,"height":60,
"strokeColor":"#e03131","backgroundColor":"#ffc9c9","label":{"text":"Error"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"start"},"end":{"id":"step1"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"step1"},"end":{"id":"decide"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"decide"},"end":{"id":"end-ok"},"label":{"text":"Yes"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"decide"},"end":{"id":"end-err"},"label":{"text":"No"}}
]
}json
{
"elements": [
{"id":"start","type":"ellipse","x":160,"y":40,"width":120,"height":60,
"strokeColor":"#2f9e44","backgroundColor":"#b2f2bb","label":{"text":"Start"}},
{"id":"step1","type":"rectangle","x":140,"y":160,"width":160,"height":60,
"strokeColor":"#1971c2","backgroundColor":"#a5d8ff","label":{"text":"Validate Input"}},
{"id":"decide","type":"diamond","x":140,"y":280,"width":160,"height":80,
"strokeColor":"#e8590c","backgroundColor":"#ffd8a8","label":{"text":"Valid?"}},
{"id":"end-ok","type":"ellipse","x":340,"y":290,"width":100,"height":60,
"strokeColor":"#2f9e44","backgroundColor":"#b2f2bb","label":{"text":"Success"}},
{"id":"end-err","type":"ellipse","x":0,"y":290,"width":100,"height":60,
"strokeColor":"#e03131","backgroundColor":"#ffc9c9","label":{"text":"Error"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"start"},"end":{"id":"step1"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"step1"},"end":{"id":"decide"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"decide"},"end":{"id":"end-ok"},"label":{"text":"Yes"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"decide"},"end":{"id":"end-err"},"label":{"text":"No"}}
]
}ER Diagram
ER图
json
{
"elements": [
{"id":"users","type":"rectangle","x":40,"y":100,"width":180,"height":120,
"strokeColor":"#1971c2","backgroundColor":"#a5d8ff",
"label":{"text":"users\n─────\nid: UUID\nname: text\nemail: text"}},
{"id":"orders","type":"rectangle","x":300,"y":100,"width":180,"height":120,
"strokeColor":"#9c36b5","backgroundColor":"#eebefa",
"label":{"text":"orders\n──────\nid: UUID\nuser_id: UUID\ntotal: decimal"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"users"},"end":{"id":"orders"},
"label":{"text":"1..N"},"endArrowhead":"arrow","startArrowhead":"dot"}
]
}json
{
"elements": [
{"id":"users","type":"rectangle","x":40,"y":100,"width":180,"height":120,
"strokeColor":"#1971c2","backgroundColor":"#a5d8ff",
"label":{"text":"users\n─────\nid: UUID\nname: text\nemail: text"}},
{"id":"orders","type":"rectangle","x":300,"y":100,"width":180,"height":120,
"strokeColor":"#9c36b5","backgroundColor":"#eebefa",
"label":{"text":"orders\n──────\nid: UUID\nuser_id: UUID\ntotal: decimal"}},
{"type":"arrow","x":0,"y":0,"start":{"id":"users"},"end":{"id":"orders"},
"label":{"text":"1..N"},"endArrowhead":"arrow","startArrowhead":"dot"}
]
}Anti-Patterns to Avoid
需避免的反模式
- Overlapping elements — always leave gaps; use
excalidraw distribute - Cramped spacing — minimum 40px between shapes; 60px between diagram tiers
- Tiny fonts — never below 14px; prefer 16+ for readability
- Raw arrow coordinates — always use /
startbinding to connect to shapesend - Too many colors — limit to 3–4 fill colors per diagram
- Inconsistent sizes — same-role shapes should have identical width/height
- No labels — every shape and meaningful arrow needs descriptive text
- Flat layouts — use background zones/groups to show hierarchy
- Side panels overlapping main diagram — place at x < 0 or x > mainRight + 80
- Unchecked arrow crossings — route with waypoints if arrows would cross elements
- 元素重叠 — 务必保留间距;使用工具
excalidraw distribute - 间距过窄 — 形状之间最小间距为40px;图表分层之间最小间距为60px
- 字体过小 — 字体大小不能低于14px;优先使用16px以上以保证可读性
- 箭头使用原始坐标 — 始终使用/
start绑定来连接形状end - 颜色过多 — 每张图表的填充颜色限制在3–4种
- 尺寸不一致 — 同类型角色的形状应具有相同的宽高
- 缺少标签 — 每个形状和有意义的箭头都需要描述性文本
- 扁平化布局 — 使用背景分区/分组来展示层级结构
- 侧边面板与主图表重叠 — 放置在x < 0 或 x > 主图表右侧边缘 + 80px的位置
- 未处理箭头交叉 — 如果箭头会穿过元素,使用路径点进行路由
Pre-Drawing Checklist
绘图前检查清单
Before writing any JSON:
- Plan coordinate grid on paper (tiers, x-positions, spacing)
- Calculate shape widths:
max(160, textLength * 9) - Assign IDs to all shapes that arrows will reference
- Choose 2–3 fill colors for semantic grouping
- Decide flow direction (vertical or horizontal)
- Run for quick color reference
excalidraw guide
在编写任何JSON之前:
- 在纸上规划坐标网格(分层、x轴位置、间距)
- 计算形状宽度:
max(160, textLength * 9) - 为所有需要被箭头引用的形状分配ID
- 选择2–3种填充颜色进行语义分组
- 确定流向(垂直或水平)
- 运行快速查看颜色参考
excalidraw guide