API

Classes

class Diagram

Abstract base class for all Mermaid charts and diagrams

render(array $attributes = [])

Renders a Mermaid chart or diagram

Parameters:
  • $attributes (array) – HTML attributes for the <pre> tag as name=>value pairs

Note

The mermaid class is added

Returns:

A Mermaid chart or diagram code in a <pre> tag

Return type:

string

class Mermaid

Static helper functions

static create(string $diagram, array $frontmatter = [])

Creates an instance of a Mermaid chart or diagram

Parameters:
  • $diagram (string) – The chart/diagram class name

  • $frontmatter (array) – Chart/Diagram frontmatter configuration as name=>value pairs

Returns:

A Mermaid chart or diagram instance

Return type:

Diagram

static getId
Returns:

Returns the ID of an object. Used internally and typically not needed by application code

Return type:

string

static js(?array $config = null)
Parameters:
  • $config (array) – Mermaid initialisation configuration as name=>value pairs

Returns:

Returns the JavaScript Mermaid import and initialisation code

Return type:

string

static scriptTag(?array $config = null)
Parameters:
  • $config (array) – Mermaid initialisation configuration as name=>value pairs

Returns:

Returns the JavaScript Mermaid import and initialisation code in a <script> tag

Return type:

string

Enums

enum Direction → string

Chart/Diagram direction

case bottomTop → 'BT'

Bottom to top

case leftRight → 'LR'

Left to right

case rightLeft → 'RL'

Right to left

case topBottom → 'TB'

Top to bottom

enum InteractionTarget → string

Interaction target

case blank → '_blank'
case parent → '_parent'
case self → '_self'
case top → '_top'
enum InteractionType → string

Interaction type

case callback → 'call'