Header layout
A bar above each diagram holds its title and the copy, download and fullscreen buttons. Mermaid and hand-written SVG diagrams get the same bar.
The Mermaid diagrams on this page use Mermaid 12.1.0 with the base theme and the demo's own colours. The demo CSS also colours the nodes, lines, arrowheads, pie slices and legend keys so the diagrams match the light and dark page themes.
Live diagrams
Core infrastructure
MermaidMermaid 12.1.0 with its default ELK layout and neo look.
API report flow
MermaidMermaid 12.1.0 with its default neo look. A sequence diagram has its own layout.
Order flow with ELK
MermaidThe same flowchart as the next card. Mermaid 12 lays out a flowchart with ELK unless the diagram asks for another layout. Mermaid 12.1.0 with its default ELK layout and neo look.
Order flow with Dagre
MermaidThis copy sets layout: dagre in its own front matter. Dagre was
the default layout in Mermaid 10 and 11.
Mermaid 12.1.0 with the Dagre layout from this diagram's own config
and the default neo look.
State transition
Inline SVGNo viewBox attribute
Inline SVGAnalytics
MermaidMermaid 12.1.0 with its default neo look. A pie chart has its own layout.
Performance stress test
2,500 nodesClick or tap to open the 2,500 node grid.
Remember zoom
MermaidThis page sets rememberZoom: true. Open this diagram, zoom, pan or
rotate, then close it. Open it again and it comes back the same way. A page reload starts
fresh.
Mermaid 12.1.0 with its default ELK layout and neo look.
Meeting mode and share links
MermaidIn fullscreen, press M for a red dot that follows your pointer, and the cursor hides. Press L to copy a link that opens this diagram at the same zoom, position and rotation. Both are also in the ☰ menu. Mermaid 12.1.0 with its default ELK layout and neo look.
Security: an inline handler
Inline SVGThe node carries an onclick handler. Open the diagram fullscreen and click the
node. DiagView cleans the copy it shows in fullscreen, not the diagram on this page.
Strict and Permissive both remove every on* attribute from that
copy, so the click does nothing. Off keeps the SVG as written, so the handler runs.
The node fills with the accent colour and the label reads "Handler ran".
DiagView makes a fresh copy each time fullscreen opens, so a new Security choice applies from the next open. Strict also drops SMIL animation and CSS that could run script or load remote files. Permissive keeps both, apart from animations that rewrite links or handlers.
Why choose this layout?
Pick it when every diagram needs a visible title.
A toolbar above each diagram
A bar above each diagram holds the title and the copy, download and fullscreen buttons. With a mouse it appears on hover or keyboard focus. On touch screens it is always shown.
Keyboard and screen reader ready
Every button has a label and a visible focus ring, and the whole toolbar works from the keyboard.
A title on every diagram
The bar shows each diagram's data-title. Without one it shows the SVG's
own <title>, such as a Mermaid accTitle, and then the title Mermaid
draws on the chart. Exported files get the same name.
Keyboard reference
Tab reaches the toolbar buttons, and these keys work while the viewer is open.
Zoom
- +
- Zoom in
- -
- Zoom out
- Space / 0
- Reset & center
Pan
- ↑ ↓ ← →
- Pan
- Shift + ↑ ↓ ← →
- Fast pan
- Drag
- Free pan
Search
- F
- Open search
- Esc
- Clear / close
- Enter
- Next match
- Shift + Enter
- Previous match
Tools
- M
- Meeting mode
- R
- Rotate 90°
- L
- Share link
- T
- Text select
- ?
- Show shortcuts
Integration
Render Mermaid first, then start DiagView.
// With Mermaid, render it first
await mermaid.run();
DiagView.init({
diagramSelector:
'.mermaid, .diagram',
layout: 'header',
showKeyboardHelp: true,
highResScale: 4
});
<!-- Or set it for one diagram -->
<div
class="mermaid"
data-diagview-layout="header"
>
graph TD; A-->B;
</div>