Avalonia.Controls.Markdown.Mermaid
12.4.0
Prefix Reserved
dotnet add package Avalonia.Controls.Markdown.Mermaid --version 12.4.0
NuGet\Install-Package Avalonia.Controls.Markdown.Mermaid -Version 12.4.0
<PackageReference Include="Avalonia.Controls.Markdown.Mermaid" Version="12.4.0" />
<PackageVersion Include="Avalonia.Controls.Markdown.Mermaid" Version="12.4.0" />
<PackageReference Include="Avalonia.Controls.Markdown.Mermaid" />
paket add Avalonia.Controls.Markdown.Mermaid --version 12.4.0
#r "nuget: Avalonia.Controls.Markdown.Mermaid, 12.4.0"
#:package Avalonia.Controls.Markdown.Mermaid@12.4.0
#addin nuget:?package=Avalonia.Controls.Markdown.Mermaid&version=12.4.0
#tool nuget:?package=Avalonia.Controls.Markdown.Mermaid&version=12.4.0
Avalonia.Controls.Markdown.Mermaid
Mermaid diagrams for Avalonia.Controls.Markdown. A ```mermaid fence in a Markdown control is drawn as a native diagram: no browser, no JavaScript and no SVG.
Quick Start
Call UseMermaid() on the app builder:
public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseMermaid();
Every Markdown control in the app then draws closed ```mermaid fences as diagrams:
```mermaid
flowchart LR
A[Request] --> B{Cached?}
B -->|yes| C[Serve cache]
B -->|no| D[Render page]
```
To draw diagrams in one control only, add the extension to that control instead of calling UseMermaid() at startup; a control without it shows the fences as code:
markdown.Extensions.Add(new MermaidExtension());
MarkdownSerializer does not follow the app setting: new MarkdownSerializer(options, highlighter, [new MermaidExtension()]) reads fences into diagram blocks. UseMermaid() on a MarkdownPipelineBuilder adds the extension to a pipeline you configure yourself.
What is drawn
- Flowcharts (
flowchart/graph): every node shape, subgraphs, edge labels, solid, dotted, thick and invisible edges, all four directions, and thestyle,classDef/classandlinkStylepropertiesfill,stroke,stroke-width,colorandstroke-dasharray. - State diagrams (
stateDiagram/stateDiagram-v2): states, start and end markers, choice, fork and join, composite states and notes. - Class diagrams (
classDiagram): classes with attribute and method compartments, annotations such as<<interface>>, visibility, static (underlined) and abstract (italic) members, every relationship kind with its UML marker, cardinalities, labels, namespaces and notes. - Entity relationship diagrams (
erDiagram): entities with attribute rows (type, name, keys, comment), crow's foot cardinalities, identifying and non-identifying relationships, and labels. - Requirement diagrams (
requirementDiagram): every requirement kind with its id, text, risk and verification method, elements with their type and document reference, every relationship kind,direction, andstyle,classDef,classand:::class. - Quadrant charts (
quadrantChart): the four captioned quadrants, axis captions, labelled points with their own or aclassDef's radius, colour and stroke, and thechartWidth/chartHeightsettings. - Packet diagrams (
packet): bit-range, single-bit and+Nfields in rows, fields split across row breaks, bit numbers, and thebitsPerRow/showBitssettings. - Kanban boards (
kanban): columns and cards with wrapped text, each card's ticket and assignee, and its priority as a coloured stripe. Ticket links (ticketBaseUrl) are not clickable. - User journeys (
journey): sections as coloured bands, task cards, a face per task placed by its score, actor dots with a legend, and the timeline arrow. - Git graphs (
gitGraph,gitGraph TB:/BT:): branches as coloured lanes inorder, commits, merges, cherry-picks,HIGHLIGHTandREVERSEcommits, ids and tags, and theshowBranches,showCommitLabel,rotateCommitLabel,mainBranchNameandmainBranchOrdersettings. Commits without an id show none, where mermaid.js invents one. - Gantt charts (
gantt): sections, tasks with dates, durations,afteranduntil,done/active/critcolours, milestones,vertmarkers,excludes(weekends, weekdays, dates) andweekend friday,axisFormat,tickIntervalandweekday,dateFormatincluding Unix time, compact display mode, and a marker for today unlesstodayMarker off. The today marker is placed when the diagram is laid out, so a document left open past midnight shows yesterday until it is laid out again. - Block diagrams (
block): grids withcolumns, spans and spaces, nestedblock … endgroups with their own grid, every flowchart shape, block arrows, links with labels and line kinds, andstyle,classDefandclass. - Sequence diagrams (
sequenceDiagram): participants and actors, every arrow kind (->>,-->>,->,-->,-x,-)and bidirectional), self messages, activations by+/-oractivate/deactivate, notes left of, right of and over lifelines,loop,alt/else,opt,par/and,criticalandbreakfragments,recthighlights, boxes, and created and destroyed participants. - Pie charts (
pie): slices with their share, a legend,showDataandtitle. - XY charts (
xychart-beta, alsohorizontal): bar series side by side and line series, named or numeric x axis, y-axis title and range, grid lines at round values, and a legend for named series.
Box series are not drawn yet. They, other diagram types, and source that does not parse, show as text. A failed block carries the :visualizationFailed pseudo-class. A fence that is still streaming in shows as text until its closing fence arrives, so a diagram is not redrawn on every token.
A diagram's title, from its own title statement or else from title: in its frontmatter or init directive, is drawn above it.
The document does not change: a diagram is still a fenced code block, so it serializes, copies and searches as its source.
Theming
Diagrams follow the theme variant through ordinary resources. The package carries a light and a dark colour scheme of its own (softly tinted, rounded boxes with a light shadow, rounded edge bends, and labels on pills), so nothing has to be included. Any colour is overridden by a resource of the same key anywhere from the diagram up to the application, including in ThemeDictionaries, and a resource changed while the app runs is drawn with at once:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="MarkdownMermaidNodeBackground" Color="#EEF6FF" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="MarkdownMermaidNodeBackground" Color="#1C2633" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Application.Resources>
| Key | Draws |
|---|---|
MarkdownMermaidNodeBackground, MarkdownMermaidNodeBorderBrush, MarkdownMermaidNodeForeground |
Nodes, participants, classes, entities and other boxes |
MarkdownMermaidEdgeBrush |
Edge lines and arrowheads |
MarkdownMermaidEdgeLabelBackground, MarkdownMermaidEdgeLabelForeground |
Edge labels and free text such as axis labels |
MarkdownMermaidClusterBackground, MarkdownMermaidClusterBorderBrush, MarkdownMermaidClusterForeground |
Subgraphs, composite states, namespaces, grid lines |
MarkdownMermaidNoteBackground, MarkdownMermaidNoteBorderBrush, MarkdownMermaidNoteForeground |
Notes, and the faces of a user journey |
MarkdownMermaidShadowColor |
The shadow under boxes: a colour or a solid brush; Transparent draws diagrams flat |
MarkdownMermaidAccent0Brush to MarkdownMermaidAccent7Brush |
Areas and series a diagram tells apart: a quadrant chart's quadrants, a kanban card's priority, a journey's sections and actors, a git graph's branches, a gantt chart's sections and task states, a pie's slices, an xy chart's series |
A variant based on Dark (new ThemeVariant("Dim", ThemeVariant.Dark)) takes the dark scheme; any other variant takes the light one unless the application gives it colours. A resource of the wrong type, such as a Color under a brush key, is passed over.
Styles in the diagram source take precedence over the theme. A sequence box or rect colour that is fully opaque is drawn as a translucent tint, so the theme's lines and text stay readable on it.
Requirements
- .NET 8 or .NET 10
Avalonia.Controls.Markdown
Dependencies
Avalonia.Controls.Markdown
The Mermaid parsers and the Sugiyama graph layout engine are compiled into the package from the Mermaider fork, with their types internal, so they add no package references and do not clash with an app's own Mermaider or Sugiyama reference. See NOTICE.md for their licences.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Avalonia (>= 12.0.3)
- Avalonia.Controls.Markdown (= 12.4.0)
-
net8.0
- Avalonia (>= 12.0.3)
- Avalonia.Controls.Markdown (= 12.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 12.4.0 | 1,726 | 10/28/2026 |
## 12.4.0
### Features
- First release. `AppBuilder.UseMermaid()` at startup makes every `Markdown` control in the app draw closed ` ```mermaid ` fences as native diagrams. `MermaidExtension`, the Markdig extension behind it, can instead be added to one control's `Markdown.Extensions`, passed to `MarkdownSerializer`, or added to a pipeline with `MarkdownPipelineBuilder.UseMermaid()`. Flowcharts and state diagrams are drawn, with subgraphs, composite states, notes, edge labels and the `style`, `classDef` and `linkStyle` colour and stroke properties. Class diagrams (compartments, annotations, UML relationship markers, cardinalities, namespaces, notes), entity relationship diagrams (attribute rows, crow's foot cardinalities), requirement diagrams (requirement and element boxes, relationship kinds), quadrant charts (tinted quadrants, styled points), packet diagrams (bit fields in rows), kanban boards (columns, cards, priorities), user journeys (sections, scored tasks, actors), git graphs (branches, merges, cherry-picks, tags), gantt charts (time axis, task states, milestones, markers, compact mode), block diagrams (grids, groups, shapes, block arrows, links), pie charts (slices, shares, legend, showData), xy charts (bar and line series, vertical or horizontal, axis titles and range) and sequence diagrams (actors, every arrow kind, activations, notes, fragments, boxes, created and destroyed participants) are drawn too. Box series in xy charts and other diagram types show as text. Diagrams follow the light and dark theme variants with a built-in colour scheme for each (tinted rounded boxes, soft shadows, rounded edge bends, pill labels), take overrides from ordinary resources and `ThemeDictionaries` (`MarkdownMermaidNodeBackground`, `MarkdownMermaidNodeBorderBrush`, `MarkdownMermaidNodeForeground` and the like, `MarkdownMermaidShadowColor`) and redraw when one changes, use eight accent colours (`MarkdownMermaidAccent0Brush` to `MarkdownMermaidAccent7Brush`) to tell areas and series apart, draw their frontmatter or init title above them, scale down to fit a narrow view, and are parsed and laid out off the UI thread. The document is unchanged: a diagram is still a fenced code block for serialization, copy and search. Targets net8.0 and net10.0 with no package dependency beyond `Avalonia.Controls.Markdown`: the Mermaid parsers and the Sugiyama layout engine are compiled in. It depends on the `Avalonia.Controls.Markdown` package of exactly its own version, since it builds on that package's internals.