beautiful-mermaid
FreeRuns bundled scriptsNot checkedRender Mermaid diagrams as beautiful SVG, PNG, or ASCII art. Supports 6 chart types (flowchart, sequence, state, class, ER, XY chart), 16 built-in themes, 5…
by sunshinejnjn131 installs in other catalogsAbout this skill
Beautiful Mermaid Skill
概述
Beautiful Mermaid 是一个高性能的 Mermaid 图表渲染库,专为 AI 时代设计。它将 Mermaid 语法转换为美观的 SVG 图形、PNG 位图或 ASCII 艺术字,支持同步渲染、全主题定制、CSS级样式定制,零 DOM 依赖。
| 说明 | 地址 |
|---|---|
| 本 Skill | https://github.com/chouraycn/beautiful-mermaid |
| 上游项目 | https://github.com/lukilabs/beautiful-mermaid |
核心能力
1. 支持的图表类型
- 流程图 (Flowchart):
graph TD、graph LR、graph BT、graph RL等方向 - 序列图 (Sequence Diagram):参与者之间的交互
- 状态图 (State Diagram):状态转换
- 类图 (Class Diagram):面向对象设计
- 实体关系图 (ER Diagram):数据库设计
- XY 图表:条形图、折线图、组合图(
xychart-beta语法)
2. 输出格式
- SVG:适用于富 UI 界面,支持透明背景和内联样式
- PNG:适用于文档嵌入、高清位图输出,支持自定义尺寸和 DPI
- ASCII/Unicode:适用于终端环境,支持颜色输出
3. 主题系统
- 15 内置主题:tokyo-night、dracula、github-dark、nord 等(9 暗色 + 6 亮色)
- 完整 7 字段:每个主题包含
bg、fg、line、accent、muted、surface、border全部字段 - Mono 模式:仅需提供背景色(bg)和前景色(fg),自动推导整套配色
- 自定义主题:可覆盖任意元素颜色
- Shiki 集成:通过
fromShikiTheme()直接使用 VS Code 编辑器主题
主题完整对照表
| 主题名 | 类型 | 背景色 | 强调色(accent) | 推荐预设 | 适用场景 |
|---|---|---|---|---|---|
zinc-light |
亮色 | #FFFFFF |
#3F3F46 |
outline | 极简文档 |
zinc-dark |
暗色 | #18181B |
#A1A1AA |
glass | 极简暗场景 |
tokyo-night |
暗色 | #1a1b26 |
#7aa2f7 |
glass | 代码架构图 |
tokyo-night-storm |
暗色 | #24283b |
#7aa2f7 |
modern | 系统设计图 |
tokyo-night-light |
亮色 | #d5d6db |
#34548a |
modern | 亮色演示 |
catppuccin-mocha |
暗色 | #1e1e2e |
#cba6f7 |
glass | 产品展示 |
catppuccin-latte |
亮色 | #eff1f5 |
#8839ef |
modern | 分享文档 |
nord |
暗色 | #2e3440 |
#88c0d0 |
modern | 技术文档暗色 |
nord-light |
亮色 | #eceff4 |
#5e81ac |
outline | 技术文档亮色 |
dracula |
暗色 | #282a36 |
#bd93f9 |
gradient | 视觉展示 |
github-light |
亮色 | #ffffff |
#0969da |
default | GitHub/文档 |
github-dark |
暗色 | #0d1117 |
#4493f8 |
modern | 代码深度分析 |
solarized-light |
亮色 | #fdf6e3 |
#268bd2 |
outline | 护眼亮色 |
solarized-dark |
暗色 | #002b36 |
#268bd2 |
modern | 护眼暗色 |
one-dark |
暗色 | #282c34 |
#c678dd |
gradient | 紫色调 |
主题字段说明
| 字段 | 说明 | 用途 |
|---|---|---|
bg |
画布背景色 | 整体底色 |
fg |
主前景/文字色 | 节点标签、主要文字 |
line |
连线颜色 | 边/箭头连线 |
accent |
强调色 | 箭头头部、子图标题、高亮节点 |
muted |
次要色 | 边标签、辅助注释文字 |
surface |
节点填充次级色 | 比 bg 深/浅一级,用于节点内填充 |
border |
节点边框精确色 | 节点外框描边 |
推荐主题 × 预设搭配
tokyo-night + glass → 代码架构图的最佳组合(深蓝毛玻璃)
dracula + gradient → 视觉展示最强(紫色渐变阴影)
github-light + default → 文档嵌入首选(简洁中性)
catppuccin-mocha + glass → 产品 Deck 展示(柔和紫色调)
nord + modern → 技术报告暗色版(冰蓝现代感)
one-dark + gradient → 紫色调视觉最强(彩色阴影)
orange-dark + glass → 暖色系深色主题(橙色毛玻璃)
orange-light + modern → 暖色系浅色主题(橙色现代感)
AI 预览工作规则(最高优先级):任何涉及渲染 Mermaid 图表的请求,无论用户是否已指定主题/预设,都必须先调用
preview_url打开预览工具,让用户在 preview.html 中直观确认效果后,再执行渲染命令。触发场景(包括但不限于):
- 用户询问主题/配色推荐
- 用户已明确指定主题和预设(如"用 tokyo-night + glass 渲染")→ 仍需先打开 preview 让用户确认,不得跳过
- 需要查看图表效果
- 任何使用 skill 渲染图表的场景
打开方式(唯一合法方式):
- 工具:
preview_url- URL:
file://{__SKILL_DIR__}/assets/preview.html(__SKILL_DIR__为技能安装目录的绝对路径)唯一例外:用户明确说"直接渲染,不用预览"或"跳过预览"时,才可跳过 preview 步骤。
禁止:
- 使用
open/start/xdg-open等命令打开系统浏览器- 启动
python3 -m http.server或任何本地 HTTP 服务- 用户未明确说跳过时,擅自跳过 preview 直接执行渲染
用户打开预览后,可在 Themes 和 Presets 标签页中直接点击切换对比效果。
4. 样式定制系统
- 节点样式:圆角、边框、阴影、填充色
- 连线样式:粗细、颜色、箭头、圆角
- 字体排版:支持多种字体和响应式适配
- 5种预设风格:默认、现代简约、渐变、线条轮廓、毛玻璃
使用方法
安装
npm install beautiful-mermaid
# 或
bun add beautiful-mermaid
交互式预览工具
提供可视化的样式定制界面,AI 必须用 preview_url 工具直接以文件路径打开(在 IDE 内置浏览器中显示,无需服务器):
preview_url(`file://{__SKILL_DIR__}/assets/preview.html`)
❌ 禁止使用 open/start 命令或启动任何 HTTP 服务器。
预览工具功能:
- 15 主题即时预览:点击切换,实时查看效果
- 5 种样式预设:default / modern / gradient / outline / glass
- 自定义颜色:背景色、前景色、连线颜色
- 9 种图表类型:Flowchart、Sequence、State、Class、ER、Bar、Line、Combo、H-Bar
- 实时代码编辑器:支持自定义 Mermaid 代码,Tab 缩进,400ms debounce 自动渲染
- 状态持久化:所有选择(主题、预设、颜色、自定义代码)自动保存到 localStorage
- 一键导出:复制代码或导出带完整样式的 SVG 文件
丰富结果 HTML(多图表聚合展示)
当用户需要将多张 Mermaid 图表整合为一个专业的展示页面时,使用 scripts/rich-html.js。
生成的 HTML 包含:
- 顶部 Badge(显示主题和预设)+ 标题 + 副标题
- 标签页导航(每张图表对应一个 Tab,支持 ① ② ③ … 编号)
- 每个 Tab 内的信息卡片网格(图表类型 + 自定义元数据)
- 卡片式 SVG 图表区(带图标、标题、描述)
- 底部页脚(渲染信息)
- 完整继承用户选择的主题风格(背景、前景、强调色等)
基本用法
# 方式一:直接调用脚本
node scripts/rich-html.js "标题" \
--diagrams file1.mmd file2.mmd file3.mmd \
--theme tokyo-night --preset glass \
--subtitle "副标题" \
--output result.html
# 方式二:通过 npm script(等效)
npm run rich-html -- "标题" \
--diagrams file1.mmd file2.mmd file3.mmd \
--theme tokyo-night --preset glass \
--subtitle "副标题" \
--output result.html
批量模式(渲染整个目录)
node scripts/rich-html.js "示例集" \
--batch assets/examples \
--theme dracula --preset
Install beautiful-mermaid in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the beautiful-mermaid skill do?
Render Mermaid diagrams as beautiful SVG, PNG, or ASCII art. Supports 6 chart types (flowchart, sequence, state, class, ER, XY chart), 16 built-in themes, 5 style presets, CSS-level customization, interactive preview, and batch rendering. Works in terminal, chat, or web environments.
How do I install the beautiful-mermaid skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the beautiful-mermaid skill run scripts?
Yes, this skill bundles executable scripts. Review the source before installing.
Related skills
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
by Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
by Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
by Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
by Anthropic