Code & DataDiagram

Diagram

Renders diagrams from code blocks using Mermaid.js. The code block content is rendered as an SVG diagram in the browser.

Basic usage

Wrap a Mermaid code block with the diagram rune to render it as an SVG.

{% diagram language="mermaid" title="User Authentication Flow" %}
```mermaid
graph TD
  A[Visit Site] --> B{Logged In?}
  B -->|Yes| C[Dashboard]
  B -->|No| D[Login Page]
  D --> E[Sign Up]
  D --> F[Sign In]
  F --> C
  E --> C
```
{% /diagram %}
<rf-diagram data-rune="diagram" data-rune-fields="{&quot;language&quot;:&quot;mermaid&quot;}">
  <figcaption data-name="title">User Authentication Flow</figcaption>
  <div data-name="container">
    <pre data-name="source">
      <code>graph TD
  A[Visit Site] --&gt; B{Logged In?}
  B --&gt;|Yes| C[Dashboard]
  B --&gt;|No| D[Login Page]
  D --&gt; E[Sign Up]
  D --&gt; F[Sign In]
  F --&gt; C
  E --&gt; C
</code>
    </pre>
  </div>
  <template data-content="source">graph TD
  A[Visit Site] --&gt; B{Logged In?}
  B --&gt;|Yes| C[Dashboard]
  B --&gt;|No| D[Login Page]
  D --&gt; E[Sign Up]
  D --&gt; F[Sign In]
  F --&gt; C
  E --&gt; C
</template>
</rf-diagram>
User Authentication Flow
graph TD
  A[Visit Site] --> B{Logged In?}
  B -->|Yes| C[Dashboard]
  B -->|No| D[Login Page]
  D --> E[Sign Up]
  D --> F[Sign In]
  F --> C
  E --> C
<rf-diagram class="rf-diagram" data-language="mermaid" data-rune="diagram" data-density="compact">
  <figcaption data-name="title" class="rf-diagram__title">User Authentication Flow</figcaption>
  <div data-name="container" class="rf-diagram__container">
    <pre data-name="source" class="rf-diagram__source"><code>graph TD
  A[Visit Site] --&gt; B{Logged In?}
  B --&gt;|Yes| C[Dashboard]
  B --&gt;|No| D[Login Page]
  D --&gt; E[Sign Up]
  D --&gt; F[Sign In]
  F --&gt; C
  E --&gt; C
</code></pre>
  </div>
  <template data-content="source">graph TD
  A[Visit Site] --&gt; B{Logged In?}
  B --&gt;|Yes| C[Dashboard]
  B --&gt;|No| D[Login Page]
  D --&gt; E[Sign Up]
  D --&gt; F[Sign In]
  F --&gt; C
  E --&gt; C
</template>
</rf-diagram>

Attributes

AttributeTypeDefaultDescription
languagestringmermaidDiagram language: mermaid, plantuml, or ascii
titlestringAccessible title for the diagram

Common attributes

All block runes share these attributes for layout and theming.

AttributeTypeDefaultDescription
widthstringcontentPage grid width: content, wide, or full
spacingstringVertical spacing: flush, tight, default, loose, or breathe
insetstringHorizontal padding: flush, tight, default, loose, or breathe
tintstringNamed colour tint from theme configuration
tint-modestringautoColour scheme override: auto, dark, or light
bgstringNamed background preset from theme configuration