Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Mermaid Diagram Field

331 sites Security covered Drupal 9–11
View on drupal.org

This module adds a field to your Drupal site that allows you to create and display diagrams using Mermaid code. It includes subfields for a title, the diagram itself, and an accessibility-focused caption, with an optional key and a setting to show the source code. You can also configure diagrams to be displayed in a modal window.

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.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
7
Tracked since
Feb 2025
Latest release
4 months ago
Releases (12 mo)
6 ▲ from 1
Maintenance
Active

Release Timeline

Releases

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