2.10.0
中文
Skip to content

Mermaid ​

Render Mermaid diagrams. Aligned with React @ant-design/x Mermaid (2.10).

Standalone component. The Markdown plugin Mermaid is still available; the two serve different purposes (plugin ≠ this component).

中文:Mermaid 图表

When to use ​

  • Render interactive Mermaid graphs with zoom, pan, and image/code views.
  • Combine with XMarkdown via components.code to render mermaid fences.

Examples ​

Basic ​

Basic

Basic usage.

Custom header ​

Login Flow
Custom header

Customize the header with header. Pass null / false to hide the default header.

Header actions ​

Header Actions Configuration

Header actions

Control zoom / download / copy and custom actions with actions.

With XMarkdown ​

With XMarkdown

Use it as components.code inside Bubble + XMarkdown to render mermaid fences.

API ​

MermaidProps ​

PropDescriptionTypeDefaultVersion
childrenMermaid source (or default slot)string--
headerHeader content; hidden when null / falseVNode | string | (() => …) | false | null--
classNamesSemantic class namesPartial\<Record<'root' | 'header' | 'graph' | 'code', string\>\>--
stylesSemantic stylesPartial\<Record<'root' | 'header' | 'graph' | 'code', CSSProperties\>\>--
highlightPropsHighlighter options for the code viewRecord\<string, unknown\>--
configmermaid.initialize config (keep the reference stable)MermaidConfig--
actionsToolbar{ enableZoom?: boolean; enableDownload?: boolean; enableCopy?: boolean; customActions?: ItemType[] }{ enableZoom: true, enableDownload: true, enableCopy: true }-
onRenderTypeChangeView switch callback(value: 'image' | 'code') => void--
prefixClsClass prefixstring--
rootClassNameExtra class on the rootstring--
styleRoot styleCSSProperties--

Slots ​

SlotDescription
defaultMermaid source
headerCustom header

Mermaid Ref ​

PropDescriptionType
nativeElementNative DOM nodeHTMLElement

SemanticType ​

NameDescription
rootRoot
headerHeader container
graphGraph container
codeCode container

Semantic DOM ​

  • root
    根节点
  • header
    头部
  • graph
    图表区
  • code
    代码区

Design Token ​

TokenDescriptionDefault
colorBgTitleTitle backgroundcolorFillContent
colorTextTitleTitle textcolorText
colorBorderCodeCode block bordercolorBorderSecondary
colorBorderGraphGraph bordercolorBorderSecondary

FAQ ​

How do I avoid re-render / re-init when using config? ​

Keep config referentially stable. Do not pass an object literal in the template (such as :config="{ theme: 'base' }"), or every parent re-render will re-initialize Mermaid.

Preferred:

ts
import { computed } from 'vue';

const config = computed(() => ({
  theme: isDark.value ? 'dark' : 'base',
  fontFamily: 'monospace',
}));

const CONFIG = { theme: 'base', fontFamily: 'monospace' } as const;

Contributors ​

Contributors

Loading contributors…