"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["30165"],{65292:function(e,r,n){n.r(r),n.d(r,{metadata:()=>t,contentTitle:()=>u,default:()=>h,assets:()=>c,toc:()=>d,frontMatter:()=>l});var t=JSON.parse('{"id":"guides/markdown-features/diagrams","title":"Diagrams","description":"Writing diagrams with Mermaid","source":"@site/docs/guides/markdown-features/markdown-features-diagrams.mdx","sourceDirName":"guides/markdown-features","slug":"/markdown-features/diagrams","permalink":"/docs/markdown-features/diagrams","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/edit/main/website/docs/guides/markdown-features/markdown-features-diagrams.mdx","tags":[],"version":"current","lastUpdatedBy":"S\xe9bastien Lorber","lastUpdatedAt":1729598021000,"frontMatter":{"id":"diagrams","title":"Diagrams","description":"Writing diagrams with Mermaid","slug":"/markdown-features/diagrams"},"sidebar":"docs","previous":{"title":"Math Equations","permalink":"/docs/markdown-features/math-equations"},"next":{"title":"Head metadata","permalink":"/docs/markdown-features/head-metadata"}}'),a=n("24246"),i=n("80980"),o=n("15398"),s=n("58636");let l={id:"diagrams",title:"Diagrams",description:"Writing diagrams with Mermaid",slug:"/markdown-features/diagrams"},u="Diagrams",c={},d=[{value:"Installation",id:"installation",level:2},{value:"Usage",id:"usage",level:2},{value:"Theming",id:"theming",level:2},{value:"Mermaid Config",id:"configuration",level:2},{value:"Dynamic Mermaid Component",id:"component",level:2}];function m(e){let r={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",mermaid:"mermaid",p:"p",pre:"pre",...(0,i.a)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.header,{children:(0,a.jsx)(r.h1,{id:"diagrams",children:"Diagrams"})}),"\n",(0,a.jsxs)(r.p,{children:["Diagrams can be rendered using ",(0,a.jsx)(r.a,{href:"https://mermaid-js.github.io/mermaid/",children:"Mermaid"})," in a code block."]}),"\n",(0,a.jsx)(r.h2,{id:"installation",children:"Installation"}),"\n",(0,a.jsxs)(o.Z,{groupId:"npm2yarn",children:[(0,a.jsx)(s.Z,{value:"npm",children:(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-bash",children:"npm install --save @docusaurus/theme-mermaid\n"})})}),(0,a.jsx)(s.Z,{value:"yarn",label:"Yarn",children:(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-bash",children:"yarn add @docusaurus/theme-mermaid\n"})})}),(0,a.jsx)(s.Z,{value:"pnpm",label:"pnpm",children:(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-bash",children:"pnpm add @docusaurus/theme-mermaid\n"})})})]}),"\n",(0,a.jsxs)(r.p,{children:["Enable Mermaid functionality by adding plugin ",(0,a.jsx)(r.code,{children:"@docusaurus/theme-mermaid"})," and setting ",(0,a.jsx)(r.code,{children:"markdown.mermaid"})," to ",(0,a.jsx)(r.code,{children:"true"})," in your ",(0,a.jsx)(r.code,{children:"docusaurus.config.js"}),"."]}),"\n",(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-js",metastring:'title="docusaurus.config.js"',children:"export default {\n markdown: {\n mermaid: true,\n },\n themes: ['@docusaurus/theme-mermaid'],\n};\n"})}),"\n",(0,a.jsx)(r.h2,{id:"usage",children:"Usage"}),"\n",(0,a.jsxs)(r.p,{children:["Add a code block with language ",(0,a.jsx)(r.code,{children:"mermaid"}),":"]}),"\n",(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-md",metastring:'title="Example Mermaid diagram"',children:"```mermaid\ngraph TD;\n A--\x3eB;\n A--\x3eC;\n B--\x3eD;\n C--\x3eD;\n```\n"})}),"\n",(0,a.jsx)(r.mermaid,{value:"graph TD;\n A--\x3eB;\n A--\x3eC;\n B--\x3eD;\n C--\x3eD;"}),"\n",(0,a.jsxs)(r.p,{children:["See the ",(0,a.jsx)(r.a,{href:"https://mermaid-js.github.io/mermaid/#/./n00b-syntaxReference",children:"Mermaid syntax documentation"})," for more information on the Mermaid syntax."]}),"\n",(0,a.jsx)(r.h2,{id:"theming",children:"Theming"}),"\n",(0,a.jsxs)(r.p,{children:["The diagram dark and light themes can be changed by setting ",(0,a.jsx)(r.code,{children:"mermaid.theme"})," values in the ",(0,a.jsx)(r.code,{children:"themeConfig"})," in your ",(0,a.jsx)(r.code,{children:"docusaurus.config.js"}),". You can set themes for both light and dark mode."]}),"\n",(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-js",metastring:'title="docusaurus.config.js"',children:"export default {\n themeConfig: {\n mermaid: {\n theme: {light: 'neutral', dark: 'forest'},\n },\n },\n};\n"})}),"\n",(0,a.jsxs)(r.p,{children:["See the ",(0,a.jsx)(r.a,{href:"https://mermaid-js.github.io/mermaid/#/theming",children:"Mermaid theme documentation"})," for more information on theming Mermaid diagrams."]}),"\n",(0,a.jsx)(r.h2,{id:"configuration",children:"Mermaid Config"}),"\n",(0,a.jsxs)(r.p,{children:["Options in ",(0,a.jsx)(r.code,{children:"mermaid.options"})," will be passed directly to ",(0,a.jsx)(r.code,{children:"mermaid.initialize"}),":"]}),"\n",(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-js",metastring:'title="docusaurus.config.js"',children:"export default {\n themeConfig: {\n mermaid: {\n options: {\n maxTextSize: 50,\n },\n },\n },\n};\n"})}),"\n",(0,a.jsxs)(r.p,{children:["See the ",(0,a.jsx)(r.a,{href:"https://mermaid-js.github.io/mermaid/#/./Setup?id=configuration",children:"Mermaid config documentation"})," and the ",(0,a.jsx)(r.a,{href:"https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.type.ts",children:"Mermaid config types"})," for the available config options."]}),"\n",(0,a.jsx)(r.h2,{id:"component",children:"Dynamic Mermaid Component"}),"\n",(0,a.jsxs)(r.p,{children:["To generate dynamic diagrams, you can use the ",(0,a.jsx)(r.code,{children:"Mermaid"})," component:"]}),"\n",(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-mdx",metastring:'title="Example of dynamic Mermaid component"',children:"import Mermaid from '@theme/Mermaid';\n\n\n"})})]})}function h(e={}){let{wrapper:r}={...(0,i.a)(),...e.components};return r?(0,a.jsx)(r,{...e,children:(0,a.jsx)(m,{...e})}):m(e)}},58636:function(e,r,n){n.d(r,{Z:()=>o});var t=n("24246");n("27378");var a=n("90496");let i="tabItem_pnkT";function o(e){var r=e.children,n=e.hidden,o=e.className;return(0,t.jsx)("div",{role:"tabpanel",className:(0,a.Z)(i,o),hidden:n,children:r})}},15398:function(e,r,n){n.d(r,{Z:()=>k});var t=n("24246"),a=n("27378"),i=n("90496"),o=n("54947"),s=n("3620"),l=n("844"),u=n("97486"),c=n("32263"),d=n("16971");function m(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=Array(r);n child <".concat("string"==typeof e.type?e.type:e.type.name,'>: all children of the component should be , and every should have a unique "value" prop.'))}))||void 0===r?void 0:r.filter(Boolean))&&void 0!==n?n:[]}function p(e){var r=e.value;return e.tabValues.some(function(e){return e.value===r})}var g=n("71607");let b="tabList_Qoir",v="tabItem_AQgk";function j(e){for(var r=1;r0)throw Error('Docusaurus error: Duplicate values "'.concat(r.map(function(e){return e.value}).join(", "),'" found in . Every value needs to be unique.'))}(e),e},[n,t])),P=h((0,a.useState)(function(){return function(e){var r,n=e.defaultValue,t=e.tabValues;if(0===t.length)throw Error("Docusaurus error: the component requires at least one children component");if(n){if(!p({value:n,tabValues:t}))throw Error('Docusaurus error: The has a defaultValue "'.concat(n,'" but none of its children has the corresponding value. Available values are: ').concat(t.map(function(e){return e.value}).join(", "),". If you intend to show no default tab, use defaultValue={null} instead."));return n}var a=null!==(r=t.find(function(e){return e.default}))&&void 0!==r?r:t[0];if(!a)throw Error("Unexpected error: 0 tabValues");return a.value}({defaultValue:k,tabValues:M})}),2),C=P[0],T=P[1];var E=h((o=(i={queryString:void 0!==S&&S,groupId:D}).queryString,m=i.groupId,g=(0,s.k6)(),b=function(e){var r=e.queryString,n=void 0!==r&&r,t=e.groupId;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!t)throw Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return null!=t?t:null}({queryString:void 0!==o&&o,groupId:m}),[(0,u._X)(b),(0,a.useCallback)(function(e){if(!!b){var r,n,t=new URLSearchParams(g.location.search);t.set(b,e),g.replace((r=function(e){for(var r=1;r