Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

mermaid_diagram_field

323 sites Security covered
View on drupal.org
Mermaid Diagram Field

Features

This module adds two things to a Drupal site.

  • A field for adding and rendering Mermaid diagrams with the following subfields:
    • Title - a heading for the diagram
    • Diagram - this is the actual Mermaid diagram code to be rendered.
    • Caption - a caption for the diagram that should assist with A11y.
    • Key - An optional key to describe the parts of the diagram. This is optional because some mermaid diagrams make their own key, so this one is not needed.
    • Show code - checking this box will cause the code of the mermaid and key to be output into a description box for copy and pasting.
  • A twig template for rendering mermaid diagrams in code.
     [
        '#theme' => 'mermaid_diagram',
        '#preface' => (optional) Anything to be rendered beforehand.
        '#title' => [required] The title of the diagram.
        '#mermaid' => [required] Mermaid code for the diagram.
        '#caption' => [required] A message that describes the diagram.
        '#key' => (optional) Mermaid code for a key for the diagram.
        '#postface' => (optional)  Anything to be rendered after the diagram.
        '#show_code' => boolean to cause the source code to be visible for copy
        and pasting a diagram.
        '#attached' => ['library' => ['mermaid_diagram_field/diagram']],
      ],
    

Similar projects

Mermaid support

FAQs

How does the 'key' property work?

The key property is another spot for Mermaid code. However it is usually used to add a simple Mermaid that shows the meaning of the shapes used. Keep in mind that some Mermaid types like 'pie' automatically create their own key, so you don't need to provide a key. While types like a flowchart do not, so providing a key for those can be very helpful.

sample key :

flowchart LR
subgraph "Entity types"
circle(("Content"))
doubleSidedRectangle[["Media"]]
hexagon{{"Paragraph"}}
rectangle["Taxonomy term"]
end

Can the Mermaid diagram be rendered in a modal?

Yes it can. On the "Manage Display" tab the field has a setting to make it use a modal. If this is enabled, the content will be rendered as a link, that when clicked, will open the modal and display the diagram.

Activity

Total releases
7
First release
Feb 2025
Latest release
2 weeks ago
Release cadence
68 days
Stability
100% stable

Release Timeline

Releases

Version Type Release date
1.0.9 Stable Apr 4, 2026
1.0.8 Stable Jan 8, 2026
1.0.7 Stable Dec 17, 2025
1.0.6 Stable Dec 4, 2025
1.0.5 Stable Dec 3, 2025
1.0.4 Stable Nov 22, 2025
1.0.3 Stable Feb 21, 2025