Installation / インストール
1. Install required packages (npm):
npm install mermaid rehype-mermaid
npm install --save-dev playwright
npx playwright install --with-deps
Or with pnpm:
pnpm install mermaid rehype-mermaid
pnpm install -D playwright
pnpm exec playwright install --with-deps
2. Copy the component to your project:
components/
└── MermaidChart.astro
3. Configure Tailwind:
export default { darkMode: 'class', // ...}
4. Import and use:
import MermaidChart from '@/components/MermaidChart.astro';
Usage / 使い方
---import MermaidChart from "../components/MermaidChart.astro";---
<MermaidChart chart="graph TD A[Start] --> B[End] "/>
Examples / 使用例
Flowchart / フローチャート
graph TD
A[Start] --> B{Is it working?}
B -->|Yes| C[Great!]
B -->|No| D[Debug]
D --> B
Sequence Diagram / シーケンス図
sequenceDiagram
participant Browser
participant Server
participant Database
Browser->>Server: GET /api/data
Server->>Database: Query data
Database-->>Server: Return results
Server-->>Browser: Send JSON response
Props / プロパティ
Name | Type | Default | Description |
---|---|---|---|
chart | string | Required | Mermaid diagram definition Mermaid図の定義テキスト |
Features / 特徴
-
Dark mode support with automatic theme switching
ダークモードに対応し、テーマが自動的に切り替わります -
Client-side rendering with smooth transitions
クライアントサイドでのレンダリングでスムーズな遷移を実現 -
Multiple diagram types support (flowcharts, sequence diagrams, etc.)
複数の図表タイプをサポート(フローチャート、シーケンス図など) -
Simple API with TypeScript support
TypeScriptサポート付きのシンプルなAPI
Available Themes / 利用可能なテーマ
- Light mode: forest theme
- Dark mode: dark theme
-
Other available themes (can be configured in MermaidChart.astro):
- base - Simple and basic theme
- default - Default Mermaid theme
- neutral - Theme based on achromatic colors