---
name: beautiful-mermaid
description: Skill for using the beautiful-mermaid TypeScript library to render Mermaid diagrams to SVG or ASCII/Unicode, apply themes (including Shiki), and integrate in Node or browser contexts.
---
# Beautiful Mermaid
## Overview
Enable fast, themeable Mermaid rendering in Node, browser, or CLI outputs using the `beautiful-mermaid` package. Use this skill to generate SVG diagrams, ASCII/Unicode diagrams, and consistent theming.
## When To Use
- Render Mermaid diagrams to SVG or ASCII/Unicode.
- Add or customize themes (two-color base, enrichment colors, or Shiki themes).
- Integrate `beautiful-mermaid` in Node, browser, or CLI tooling.
- Troubleshoot diagram rendering, spacing, or theme output.
## Scenario Map (Use-Case Examples)
- Terminal/CLI 输出图:Use `renderMermaidAscii()` with `useAscii: true` for pure ASCII.
- 终端更美观:Use `renderMermaidAscii()` default Unicode for box-drawing.
- Web 页面/React 组件:Use `renderMermaid()` to get SVG and inject into DOM.
- 需要主题一致:Use `THEMES['...']` to apply a built-in theme.
- 需要公司品牌色:Provide `bg` + `fg` (mono) or add `accent/muted/surface`.
- 需要跟 VS Code 主题一致:Use Shiki + `fromShikiTheme()`.
- CDN/无打包环境:Use the browser global bundle via `
```
### Live Theme Switching
- Update SVG CSS custom properties (no re-render required).
```js
svg.style.setProperty('--bg', '#282a36')
svg.style.setProperty('--fg', '#f8f8f2')
```
### Troubleshooting
- If render fails, validate Mermaid syntax and diagram type.
- For terminal alignment, prefer Unicode or set `preserveDisplayWidth: true`.
- For browser usage, ensure the global bundle is loaded before use.
## Resources
- Reference API details and theme lists in `references/beautiful-mermaid-reference.md`.
- `references/api-render.md`: renderMermaid 参数表、误区与示例
- `references/api-ascii.md`: renderMermaidAscii 参数表、误区与示例
- `references/themes-and-shiki.md`: 主题模型、内置主题与 Shiki 集成