Mermaid
Create interactive diagrams and flowcharts using text-based Mermaid syntax for visualizing laboratory workflows, processes, and experimental designs
Overview
The Mermaid section widget enables laboratory professionals to create and embed interactive diagrams directly within Labii records using text-based syntax. Built on the powerful Mermaid JavaScript library, this widget transforms simple text descriptions into professional-quality diagrams, including flowcharts, sequence diagrams, Gantt charts, class diagrams, and more. The widget is particularly valuable for documenting experimental workflows, process flows, project timelines, and system architectures without requiring specialized diagramming software. With integrated AI assistance, users can generate complex diagrams from natural language descriptions, making diagram creation accessible to both technical and non-technical laboratory staff.
Use Cases
Experimental Protocol Visualization: Create flowcharts documenting step-by-step experimental procedures with decision points and conditional branches
Laboratory Workflow Mapping: Design process flow diagrams showing sample handling, testing sequences, and quality control checkpoints
Project Timeline Management: Build Gantt charts for research projects, showing task dependencies and milestone tracking
Interface
Read-only View
The read-only view displays the rendered diagram in its final visual form. Users can view the complete diagram with all formatting, colors, and styling applied according to the selected theme. The diagram is fully interactive, allowing users to zoom and pan when viewing complex or large diagrams. Any hyperlinks embedded within diagram elements are clickable, enabling navigation to related documentation or external resources. The view automatically scales diagrams to fit within the section container while maintaining aspect ratio and clarity.

Edit View
The edit view provides a split-screen interface with a text editor on the left and a live preview pane on the right. As users type or modify the Mermaid syntax, the preview updates in real-time, allowing immediate visualization of changes. The text editor includes syntax highlighting for Mermaid code, making it easier to identify diagram elements, relationships, and formatting directives.

Key features of the edit interface include:
Code Editor: Write or edit Mermaid syntax with line numbering and basic text editing capabilities
Live Preview: Real-time rendering of diagrams as you type, showing exactly how the final diagram will appear
AI Assistant: Access AI-powered diagram generation through a dedicated button, allowing natural language description of desired diagrams
Theme Selection: Choose from multiple visual themes (Default, Forest, Dark, Neutral) to match documentation style or organizational branding
Insert/Replace Controls: When using AI generation, choose to insert generated code at cursor position or replace existing content entirely
Syntax Validation: Automatic detection of syntax errors with helpful error messages to guide corrections
The editor supports all standard text editing operations including copy, paste, undo, and redo, making it easy to iterate on diagram designs and incorporate feedback.
Configuration
Adding the Mermaid Widget
Navigate to the record where you want to add a diagram and click Add Section
Select Mermaid from the section widget options
Click Edit to open the diagram editor and begin creating your diagram
Creating a Basic Diagram
In the edit view, enter your Mermaid syntax in the text editor. For a simple flowchart:
Select your preferred theme from the theme dropdown:
Default: Clean, minimalist styling with blue accents
Forest: Green color palette suitable for environmental or biological documentation
Dark: High contrast dark theme for presentations or reduced eye strain
Neutral: Grayscale professional styling for formal documentation
Click Submit to save the diagram. The rendered diagram will display in read-only view
Using AI Assistant to Generate Diagrams
Click the AI Assistant button in the diagram editor
Describe your desired diagram in natural language. Example: "Create a flowchart showing a protein purification workflow with centrifugation, column chromatography, and quality control steps"
Press Enter to submit your prompt
Review the AI-generated Mermaid code in the preview pane. The AI will create syntactically correct Mermaid code based on your description
Choose your insertion method:
Click Insert to add the generated code at the current cursor position
Click Replace to replace all existing diagram code with the generated version
Refine the generated code as needed and select your preferred theme
Click Submit to save the completed diagram
The AI Assistant is particularly helpful for users unfamiliar with Mermaid syntax or when creating complex diagrams quickly. You can always edit the AI-generated code to customize the diagram further.
Additional Functions
Supported Diagram Types
The Mermaid widget supports all diagram types available in the Mermaid library:
Flowcharts
Standard directed graph diagrams for representing processes, decisions, and workflows. Supports multiple orientations (top-down, left-right, bottom-up) and various node shapes (rectangles, rounded rectangles, circles, diamonds, hexagons).
Documentation: https://mermaid-js.github.io/mermaid/#/flowchart
Sequence Diagrams
Interaction diagrams showing how processes, systems, or objects communicate with one another and in what order. Ideal for documenting system integrations, API interactions, and multi-step automated workflows.
Documentation: https://mermaid-js.github.io/mermaid/#/sequenceDiagram
Class Diagrams
Object-oriented modeling diagrams showing system structure, class relationships, and data models. Useful for documenting software architecture, database schemas, and data relationship models.
Documentation: https://mermaid-js.github.io/mermaid/#/classDiagram
State Diagrams
Diagrams describing system behavior through finite states and transitions. Excellent for documenting equipment states, sample lifecycle stages, and process control logic.
Documentation: https://mermaid-js.github.io/mermaid/#/stateDiagram
Gantt Charts
Project schedule visualizations showing task timelines, dependencies, and milestones. Essential for research project planning, resource allocation, and deadline tracking.
Documentation: https://mermaid-js.github.io/mermaid/#/gantt
Pie Charts
Circular statistical graphics displaying numerical proportions. Useful for visualizing resource allocation, sample composition, or categorical data distributions.
Documentation: https://mermaid-js.github.io/mermaid/#/pie
References
Official Mermaid Resources
Mermaid Official Documentation - Comprehensive syntax guide and examples
Mermaid Live Editor - Online tool for testing and developing Mermaid diagrams before adding to Labii
Mermaid GitHub Repository - Source code, issue tracking, and community discussions
Diagram Type References
Flowchart Syntax - Complete flowchart creation guide
Sequence Diagram Syntax - Interaction diagram documentation
Class Diagram Syntax - Object-oriented modeling reference
State Diagram Syntax - State machine documentation
Gantt Chart Syntax - Project timeline creation guide
Pie Chart Syntax - Proportional visualization reference
Last updated