beautiful-mermaid
Mermaid図をSVGやASCII/Unicodeで描画し、Shikiを含むテーマを適用して、Nodeやブラウザで統合利用するSkill。
📜 元の英語説明(参考)
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.
🇯🇵 日本人クリエイター向け解説
Mermaid図をSVGやASCII/Unicodeで描画し、Shikiを含むテーマを適用して、Nodeやブラウザで統合利用するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Beautiful Mermaid
概要
beautiful-mermaid パッケージを使用して、Node、ブラウザ、または CLI 出力で高速かつテーマ設定可能な Mermaid レンダリングを可能にします。このスキルを使用して、SVG 図、ASCII/Unicode 図、および一貫したテーマ設定を生成します。
使用する場面
- Mermaid 図を SVG または ASCII/Unicode にレンダリングする場合。
- テーマ(2色ベース、エンリッチメントカラー、または Shiki テーマ)を追加またはカスタマイズする場合。
beautiful-mermaidを Node、ブラウザ、または CLI ツールに統合する場合。- 図のレンダリング、間隔、またはテーマ出力のトラブルシューティングを行う場合。
シナリオマップ(ユースケース例)
- Terminal/CLI 出力図:純粋な ASCII の場合は
renderMermaidAscii()をuseAscii: trueとともに使用します。 - 端末をより美しく:ボックス描画には
renderMermaidAscii()のデフォルト Unicode を使用します。 - Web ページ/React コンポーネント:SVG を取得して DOM に挿入するには
renderMermaid()を使用します。 - テーマの一貫性が必要な場合:組み込みテーマを適用するには
THEMES['...']を使用します。 - 会社のブランドカラーが必要な場合:
bg+fg(モノラル) を提供するか、accent/muted/surfaceを追加します。 - VS Code テーマとの一貫性が必要な場合:Shiki +
fromShikiTheme()を使用します。 - CDN/バンドルなし環境:
<script>タグを介してブラウザのグローバルバンドルを使用します。 - リアルタイムのスキン変更が必要な場合:再レンダリングせずに SVG CSS 変数(
--bg、--fg)を更新します。
場面例(対象者別)
プログラマー/エンジニア
- CLI/端末出力図:
renderMermaidAscii()+ ASCII 互換性を使用します。import { renderMermaidAscii } from 'beautiful-mermaid' const ascii = renderMermaidAscii('graph LR; A-->B', { useAscii: true }) - Web/React 埋め込み SVG:
renderMermaid()を使用して SVG 文字列を生成します。import { renderMermaid } from 'beautiful-mermaid' const svg = await renderMermaid('graph TD; A-->B') - CI/ドキュメント生成:SVG ファイルを一括レンダリングします。
import { renderMermaid } from 'beautiful-mermaid' const svg = await renderMermaid('sequenceDiagram\nA->>B: ping') - テーマの統一:組み込みテーマまたはカスタムカラーを使用します。
import { renderMermaid, THEMES } from 'beautiful-mermaid' const svg = await renderMermaid('graph TD; A-->B', THEMES['tokyo-night'])
非技術ユーザー
- 運用/製品ドキュメント:SVG をエクスポートしてドキュメントに埋め込みます。
import { renderMermaid } from 'beautiful-mermaid' const svg = await renderMermaid('graph TD; A-->B') - 会議/レポートのスタイル統一:テーマカラーを使用して一貫性を保ちます。
import { renderMermaid } from 'beautiful-mermaid' const svg = await renderMermaid('graph TD; A-->B', { bg: '#0f0f0f', fg: '#e0e0e0' }) - 講義/デモンストレーション:端末内で ASCII/Unicode を表示します。
import { renderMermaidAscii } from 'beautiful-mermaid' const unicode = renderMermaidAscii('graph LR; A-->B') - デザインの一貫性:Shiki テーマを使用してエディタのスタイルをマッピングします。
import { getSingletonHighlighter } from 'shiki' import { renderMermaid, fromShikiTheme } from 'beautiful-mermaid' const highlighter = await getSingletonHighlighter({ themes: ['vitesse-dark'] }) const colors = fromShikiTheme(highlighter.getTheme('vitesse-dark')) const svg = await renderMermaid('graph TD; A-->B', colors)
クイックスタート
- ターゲットプロジェクトに
beautiful-mermaidをインストールします。 - SVG には
renderMermaid()を、端末出力にはrenderMermaidAscii()を使用します。 - 組み込みテーマまたはカスタムカラーを適用します。
import { renderMermaid, renderMermaidAscii, THEMES } from 'beautiful-mermaid'
const svg = await renderMermaid('graph TD; A-->B', THEMES['tokyo-night'])
const ascii = renderMermaidAscii('graph LR; A-->B', { useAscii: true })
タスク
SVG のレンダリング
- パッケージから
renderMermaidをインポートします。 - Mermaid ソーステキストを渡します(図の種類を自動検出します)。
- 色、フォント、透明度に関するオプションの
RenderOptionsを提供します。
import { renderMermaid } from 'beautiful-mermaid'
const svg = await renderMermaid(`
sequenceDiagram
Alice->>Bob: Hello
`, {
bg: '#1a1b26',
fg: '#a9b1d6',
accent: '#7aa2f7',
transparent: false,
font: 'Inter'
})
ASCII/Unicode のレンダリング
renderMermaidAsciiをインポートします。- 純粋な ASCII 互換性のために
useAscii: trueを使用します。 - 間隔を調整するために
paddingX、paddingY、およびboxBorderPaddingを調整します。
import { renderMermaidAscii } from 'beautiful-mermaid'
const unicode = renderMermaidAscii('graph LR; A-->B')
const ascii = renderMermaidAscii('graph LR; A-->B', { useAscii: true })
2色でのテーマ設定
- モノラルモードを使用するために
bgとfgのみを提供します。 - ライブラリに
color-mix()を使用して他のすべての色を派生させます。
const svg = await renderMermaid('graph TD; A-->B', {
bg: '#0f0f0f',
fg: '#e0e0e0'
})
エンリッチメントカラーでのテーマ設定
line、accent、muted、surface、borderのいずれかを追加して派生を上書きします。- 重要なエンリッチメントのみを提供します。
const svg = await renderMermaid('graph TD; A-->B', {
bg: '#1a1b26',
fg: '#a9b1d6',
accent: '#7aa2f7',
line: '#3d59a1',
muted: '#565f89',
surface: '#292e42',
border: '#3d59a1'
})
組み込みテーマの使用
THEMESをインポートし、15種類のプリセットテーマのいずれかを渡します。
import { renderMermaid, THEMES } from 'beautiful-mermaid'
const svg = await renderMermaid('graph TD; A-->B', THEMES['tokyo-night'])
Shiki テーマの使用
getSingletonHighlighterで Shiki テーマをロードします。fromShikiThemeで変換します。- 変換された色を
renderMermaidに渡します。
import { getSingletonHighlighter } from 'shiki'
import { renderMermaid, fromShikiTheme } from 'beautiful-mermaid'
const highlighter = await getSingletonHighlighter({
themes: ['vitesse-dark']
})
const colors = fromShikiTheme(highlighter.getTheme('vitesse-dark'))
const svg = await renderMermaid('graph TD; A-->B', colors)
ブラウザスクリプトタグの使用
- CDN グローバルバンドルを使用します。
beautifulMermaidのエクスポートにアクセスします。
<script src="https://unpkg.com/beautiful-mermaid/dist/beautiful-mermaid.browser.global.js"></script>
<script>
const { renderMermaid, THEMES } = beautifulMermaid
renderMermaid('graph TD; A-->B', THEMES['tokyo-night']).then(svg => {
// use svg
})
</script>
ライブテーマ切り替え
- SVG CSS カスタムプロパティを更新します(再レンダリングは不要です)。
svg.style.setProperty('--bg', '#282a36')
svg.style.setProperty('--fg', '#f8f8f2')
トラブルシューティング
- レンダリングが失敗した場合は、Mermaid 構文と図の種類を検証します。
- 端末の配置については、Unicode を優先するか、
preserveDisplayWidth: trueを設定します。 - ブラウザでの使用については、使用前にグローバルバンドルがロードされていることを確認してください。
リソース
references/beautiful-meで API の詳細とテーマリストを参照してください。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
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-mermaidin Node, browser, or CLI tooling. - Troubleshoot diagram rendering, spacing, or theme output.
Scenario Map (Use-Case Examples)
- Terminal/CLI 输出图:Use
renderMermaidAscii()withuseAscii: truefor 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 addaccent/muted/surface. - 需要跟 VS Code 主题一致:Use Shiki +
fromShikiTheme(). - CDN/无打包环境:Use the browser global bundle via
<script>tag. - 需要实时换肤:Update SVG CSS variables (
--bg,--fg) without re-render.
场景举例(按人群)
程序员/工程师
- CLI/终端输出图:Use
renderMermaidAscii()+ ASCII 兼容import { renderMermaidAscii } from 'beautiful-mermaid' const ascii = renderMermaidAscii('graph LR; A-->B', { useAscii: true }) - Web/React 内嵌 SVG:Use
renderMermaid()生成 SVG 字符串import { renderMermaid } from 'beautiful-mermaid' const svg = await renderMermaid('graph TD; A-->B') - CI/文档生成:批量渲染 SVG 文件
import { renderMermaid } from 'beautiful-mermaid' const svg = await renderMermaid('sequenceDiagram\nA->>B: ping') - 主题统一:Use 内置主题或自定义颜色
import { renderMermaid, THEMES } from 'beautiful-mermaid' const svg = await renderMermaid('graph TD; A-->B', THEMES['tokyo-night'])
非技术用户
- 运营/产品文档:导出 SVG 嵌入文档
import { renderMermaid } from 'beautiful-mermaid' const svg = await renderMermaid('graph TD; A-->B') - 会议/汇报统一风格:用主题色保持一致
import { renderMermaid } from 'beautiful-mermaid' const svg = await renderMermaid('graph TD; A-->B', { bg: '#0f0f0f', fg: '#e0e0e0' }) - 课程/演示:终端内展示 ASCII/Unicode
import { renderMermaidAscii } from 'beautiful-mermaid' const unicode = renderMermaidAscii('graph LR; A-->B') - 设计一致性:用 Shiki 主题映射编辑器风格
import { getSingletonHighlighter } from 'shiki' import { renderMermaid, fromShikiTheme } from 'beautiful-mermaid' const highlighter = await getSingletonHighlighter({ themes: ['vitesse-dark'] }) const colors = fromShikiTheme(highlighter.getTheme('vitesse-dark')) const svg = await renderMermaid('graph TD; A-->B', colors)
Quick Start
- Install
beautiful-mermaidin the target project. - Use
renderMermaid()for SVG orrenderMermaidAscii()for terminal output. - Apply a built-in theme or custom colors.
import { renderMermaid, renderMermaidAscii, THEMES } from 'beautiful-mermaid'
const svg = await renderMermaid('graph TD; A-->B', THEMES['tokyo-night'])
const ascii = renderMermaidAscii('graph LR; A-->B', { useAscii: true })
Tasks
Render SVG
- Import
renderMermaidfrom the package. - Pass Mermaid source text (auto-detects diagram type).
- Provide optional
RenderOptionsfor colors, font, and transparency.
import { renderMermaid } from 'beautiful-mermaid'
const svg = await renderMermaid(`
sequenceDiagram
Alice->>Bob: Hello
`, {
bg: '#1a1b26',
fg: '#a9b1d6',
accent: '#7aa2f7',
transparent: false,
font: 'Inter'
})
Render ASCII/Unicode
- Import
renderMermaidAscii. - Use
useAscii: truefor pure ASCII compatibility. - Adjust
paddingX,paddingY, andboxBorderPaddingto tune spacing.
import { renderMermaidAscii } from 'beautiful-mermaid'
const unicode = renderMermaidAscii('graph LR; A-->B')
const ascii = renderMermaidAscii('graph LR; A-->B', { useAscii: true })
Theme With Two Colors
- Provide only
bgandfgto use mono mode. - Let the library derive all other colors with
color-mix().
const svg = await renderMermaid('graph TD; A-->B', {
bg: '#0f0f0f',
fg: '#e0e0e0'
})
Theme With Enrichment Colors
- Add any of:
line,accent,muted,surface,borderto override derivations. - Supply only the enrichments that matter.
const svg = await renderMermaid('graph TD; A-->B', {
bg: '#1a1b26',
fg: '#a9b1d6',
accent: '#7aa2f7',
line: '#3d59a1',
muted: '#565f89',
surface: '#292e42',
border: '#3d59a1'
})
Use Built-in Themes
- Import
THEMESand pass one of the 15 preset themes.
import { renderMermaid, THEMES } from 'beautiful-mermaid'
const svg = await renderMermaid('graph TD; A-->B', THEMES['tokyo-night'])
Use Shiki Themes
- Load a Shiki theme with
getSingletonHighlighter. - Convert it with
fromShikiTheme. - Pass converted colors to
renderMermaid.
import { getSingletonHighlighter } from 'shiki'
import { renderMermaid, fromShikiTheme } from 'beautiful-mermaid'
const highlighter = await getSingletonHighlighter({
themes: ['vitesse-dark']
})
const colors = fromShikiTheme(highlighter.getTheme('vitesse-dark'))
const svg = await renderMermaid('graph TD; A-->B', colors)
Browser Script Tag Usage
- Use the CDN global bundle.
- Access exports on
beautifulMermaid.
<script src="https://unpkg.com/beautiful-mermaid/dist/beautiful-mermaid.browser.global.js"></script>
<script>
const { renderMermaid, THEMES } = beautifulMermaid
renderMermaid('graph TD; A-->B', THEMES['tokyo-night']).then(svg => {
// use svg
})
</script>
Live Theme Switching
- Update SVG CSS custom properties (no re-render required).
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 集成