collab/mermaid/docs/syntax/flowchart.mdblame
View source
6dd74de1> **Warning**
6dd74de2>
6dd74de3> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
6dd74de4>
6dd74de5> ## Please edit the corresponding file in [/packages/mermaid/src/docs/syntax/flowchart.md](../../packages/mermaid/src/docs/syntax/flowchart.md).
6dd74de6
6dd74de7# Flowcharts - Basic Syntax
6dd74de8
6dd74de9Flowcharts are composed of **nodes** (geometric shapes) and **edges** (arrows or lines). The Mermaid code defines how nodes and edges are made and accommodates different arrow types, multi-directional arrows, and any linking to and from subgraphs.
6dd74de10
6dd74de11> **Warning**
6dd74de12> If you are using the word "end" in a Flowchart node, capitalize the entire word or any of the letters (e.g., "End" or "END"), or apply this [workaround](https://github.com/mermaid-js/mermaid/issues/1444#issuecomment-639528897). Typing "end" in all lowercase letters will break the Flowchart.
6dd74de13
6dd74de14> **Warning**
6dd74de15> If you are using the letter "o" or "x" as the first letter in a connecting Flowchart node, add a space before the letter or capitalize the letter (e.g., "dev--- ops", "dev---Ops").
6dd74de16>
6dd74de17> Typing "A---oB" will create a [circle edge](#circle-edge-example).
6dd74de18>
6dd74de19> Typing "A---xB" will create a [cross edge](#cross-edge-example).
6dd74de20
6dd74de21### A node (default)
6dd74de22
6dd74de23```mermaid-example
6dd74de24---
6dd74de25title: Node
6dd74de26---
6dd74de27flowchart LR
6dd74de28 id
6dd74de29```
6dd74de30
6dd74de31```mermaid
6dd74de32---
6dd74de33title: Node
6dd74de34---
6dd74de35flowchart LR
6dd74de36 id
6dd74de37```
6dd74de38
6dd74de39> **Note**
6dd74de40> The id is what is displayed in the box.
6dd74de41
6dd74de42> **💡 Tip**
6dd74de43> Instead of `flowchart` one can also use `graph`.
6dd74de44
6dd74de45### A node with text
6dd74de46
6dd74de47It is also possible to set text in the box that differs from the id. If this is done several times, it is the last text
6dd74de48found for the node that will be used. Also if you define edges for the node later on, you can omit text definitions. The
6dd74de49one previously defined will be used when rendering the box.
6dd74de50
6dd74de51```mermaid-example
6dd74de52---
6dd74de53title: Node with text
6dd74de54---
6dd74de55flowchart LR
6dd74de56 id1[This is the text in the box]
6dd74de57```
6dd74de58
6dd74de59```mermaid
6dd74de60---
6dd74de61title: Node with text
6dd74de62---
6dd74de63flowchart LR
6dd74de64 id1[This is the text in the box]
6dd74de65```
6dd74de66
6dd74de67#### Unicode text
6dd74de68
6dd74de69Use `"` to enclose the unicode text.
6dd74de70
6dd74de71```mermaid-example
6dd74de72flowchart LR
6dd74de73 id["This ❤ Unicode"]
6dd74de74```
6dd74de75
6dd74de76```mermaid
6dd74de77flowchart LR
6dd74de78 id["This ❤ Unicode"]
6dd74de79```
6dd74de80
6dd74de81#### Markdown formatting
6dd74de82
6dd74de83Use double quotes and backticks "\` text \`" to enclose the markdown text.
6dd74de84
6dd74de85```mermaid-example
6dd74de86---
6dd74de87config:
6dd74de88 htmlLabels: false
6dd74de89---
6dd74de90flowchart LR
6dd74de91 markdown["`This **is** _Markdown_`"]
6dd74de92 newLines["`Line1
6dd74de93 Line 2
6dd74de94 Line 3`"]
6dd74de95 markdown --> newLines
6dd74de96```
6dd74de97
6dd74de98```mermaid
6dd74de99---
6dd74de100config:
6dd74de101 htmlLabels: false
6dd74de102---
6dd74de103flowchart LR
6dd74de104 markdown["`This **is** _Markdown_`"]
6dd74de105 newLines["`Line1
6dd74de106 Line 2
6dd74de107 Line 3`"]
6dd74de108 markdown --> newLines
6dd74de109```
6dd74de110
6dd74de111### Direction
6dd74de112
6dd74de113This statement declares the direction of the Flowchart.
6dd74de114
6dd74de115This declares the flowchart is oriented from top to bottom (`TD` or `TB`).
6dd74de116
6dd74de117```mermaid-example
6dd74de118flowchart TD
6dd74de119 Start --> Stop
6dd74de120```
6dd74de121
6dd74de122```mermaid
6dd74de123flowchart TD
6dd74de124 Start --> Stop
6dd74de125```
6dd74de126
6dd74de127This declares the flowchart is oriented from left to right (`LR`).
6dd74de128
6dd74de129```mermaid-example
6dd74de130flowchart LR
6dd74de131 Start --> Stop
6dd74de132```
6dd74de133
6dd74de134```mermaid
6dd74de135flowchart LR
6dd74de136 Start --> Stop
6dd74de137```
6dd74de138
6dd74de139Possible FlowChart orientations are:
6dd74de140
6dd74de141- TB - Top to bottom
6dd74de142- TD - Top-down/ same as top to bottom
6dd74de143- BT - Bottom to top
6dd74de144- RL - Right to left
6dd74de145- LR - Left to right
6dd74de146
6dd74de147## Node shapes
6dd74de148
6dd74de149### A node with round edges
6dd74de150
6dd74de151```mermaid-example
6dd74de152flowchart LR
6dd74de153 id1(This is the text in the box)
6dd74de154```
6dd74de155
6dd74de156```mermaid
6dd74de157flowchart LR
6dd74de158 id1(This is the text in the box)
6dd74de159```
6dd74de160
6dd74de161### A stadium-shaped node
6dd74de162
6dd74de163```mermaid-example
6dd74de164flowchart LR
6dd74de165 id1([This is the text in the box])
6dd74de166```
6dd74de167
6dd74de168```mermaid
6dd74de169flowchart LR
6dd74de170 id1([This is the text in the box])
6dd74de171```
6dd74de172
6dd74de173### A node in a subroutine shape
6dd74de174
6dd74de175```mermaid-example
6dd74de176flowchart LR
6dd74de177 id1[[This is the text in the box]]
6dd74de178```
6dd74de179
6dd74de180```mermaid
6dd74de181flowchart LR
6dd74de182 id1[[This is the text in the box]]
6dd74de183```
6dd74de184
6dd74de185### A node in a cylindrical shape
6dd74de186
6dd74de187```mermaid-example
6dd74de188flowchart LR
6dd74de189 id1[(Database)]
6dd74de190```
6dd74de191
6dd74de192```mermaid
6dd74de193flowchart LR
6dd74de194 id1[(Database)]
6dd74de195```
6dd74de196
6dd74de197### A node in the form of a circle
6dd74de198
6dd74de199```mermaid-example
6dd74de200flowchart LR
6dd74de201 id1((This is the text in the circle))
6dd74de202```
6dd74de203
6dd74de204```mermaid
6dd74de205flowchart LR
6dd74de206 id1((This is the text in the circle))
6dd74de207```
6dd74de208
6dd74de209### A node in an asymmetric shape
6dd74de210
6dd74de211```mermaid-example
6dd74de212flowchart LR
6dd74de213 id1>This is the text in the box]
6dd74de214```
6dd74de215
6dd74de216```mermaid
6dd74de217flowchart LR
6dd74de218 id1>This is the text in the box]
6dd74de219```
6dd74de220
6dd74de221Currently only the shape above is possible and not its mirror. _This might change with future releases._
6dd74de222
6dd74de223### A node (rhombus)
6dd74de224
6dd74de225```mermaid-example
6dd74de226flowchart LR
6dd74de227 id1{This is the text in the box}
6dd74de228```
6dd74de229
6dd74de230```mermaid
6dd74de231flowchart LR
6dd74de232 id1{This is the text in the box}
6dd74de233```
6dd74de234
6dd74de235### A hexagon node
6dd74de236
6dd74de237```mermaid-example
6dd74de238flowchart LR
6dd74de239 id1{{This is the text in the box}}
6dd74de240```
6dd74de241
6dd74de242```mermaid
6dd74de243flowchart LR
6dd74de244 id1{{This is the text in the box}}
6dd74de245```
6dd74de246
6dd74de247### Parallelogram
6dd74de248
6dd74de249```mermaid-example
6dd74de250flowchart TD
6dd74de251 id1[/This is the text in the box/]
6dd74de252```
6dd74de253
6dd74de254```mermaid
6dd74de255flowchart TD
6dd74de256 id1[/This is the text in the box/]
6dd74de257```
6dd74de258
6dd74de259### Parallelogram alt
6dd74de260
6dd74de261```mermaid-example
6dd74de262flowchart TD
6dd74de263 id1[\This is the text in the box\]
6dd74de264```
6dd74de265
6dd74de266```mermaid
6dd74de267flowchart TD
6dd74de268 id1[\This is the text in the box\]
6dd74de269```
6dd74de270
6dd74de271### Trapezoid
6dd74de272
6dd74de273```mermaid-example
6dd74de274flowchart TD
6dd74de275 A[/Christmas\]
6dd74de276```
6dd74de277
6dd74de278```mermaid
6dd74de279flowchart TD
6dd74de280 A[/Christmas\]
6dd74de281```
6dd74de282
6dd74de283### Trapezoid alt
6dd74de284
6dd74de285```mermaid-example
6dd74de286flowchart TD
6dd74de287 B[\Go shopping/]
6dd74de288```
6dd74de289
6dd74de290```mermaid
6dd74de291flowchart TD
6dd74de292 B[\Go shopping/]
6dd74de293```
6dd74de294
6dd74de295### Double circle
6dd74de296
6dd74de297```mermaid-example
6dd74de298flowchart TD
6dd74de299 id1(((This is the text in the circle)))
6dd74de300```
6dd74de301
6dd74de302```mermaid
6dd74de303flowchart TD
6dd74de304 id1(((This is the text in the circle)))
6dd74de305```
6dd74de306
6dd74de307## Expanded Node Shapes in Mermaid Flowcharts (v11.3.0+)
6dd74de308
6dd74de309Mermaid introduces 30 new shapes to enhance the flexibility and precision of flowchart creation. These new shapes provide more options to represent processes, decisions, events, data storage visually, and other elements within your flowcharts, improving clarity and semantic meaning.
6dd74de310
6dd74de311New Syntax for Shape Definition
6dd74de312
6dd74de313Mermaid now supports a general syntax for defining shape types to accommodate the growing number of shapes. This syntax allows you to assign specific shapes to nodes using a clear and flexible format:
6dd74de314
6dd74de315```
6dd74de316A@{ shape: rect }
6dd74de317```
6dd74de318
6dd74de319This syntax creates a node A as a rectangle. It renders in the same way as `A["A"]`, or `A`.
6dd74de320
6dd74de321### Complete List of New Shapes
6dd74de322
6dd74de323Below is a comprehensive list of the newly introduced shapes and their corresponding semantic meanings, short names, and aliases:
6dd74de324
6dd74de325| **Semantic Name** | **Shape Name** | **Short Name** | **Description** | **Alias Supported** |
6dd74de326| --------------------------------- | ---------------------- | -------------- | ------------------------------ | ---------------------------------------------------------------- |
6dd74de327| Bang | Bang | `bang` | Bang | `bang` |
6dd74de328| Card | Notched Rectangle | `notch-rect` | Represents a card | `card`, `notched-rectangle` |
6dd74de329| Cloud | Cloud | `cloud` | cloud | `cloud` |
6dd74de330| Collate | Hourglass | `hourglass` | Represents a collate operation | `collate`, `hourglass` |
6dd74de331| Com Link | Lightning Bolt | `bolt` | Communication link | `com-link`, `lightning-bolt` |
6dd74de332| Comment | Curly Brace | `brace` | Adds a comment | `brace-l`, `comment` |
6dd74de333| Comment Right | Curly Brace | `brace-r` | Adds a comment | |
6dd74de334| Comment with braces on both sides | Curly Braces | `braces` | Adds a comment | |
6dd74de335| Data Input/Output | Lean Right | `lean-r` | Represents input or output | `in-out`, `lean-right` |
6dd74de336| Data Input/Output | Lean Left | `lean-l` | Represents output or input | `lean-left`, `out-in` |
6dd74de337| Database | Cylinder | `cyl` | Database storage | `cylinder`, `database`, `db` |
6dd74de338| Decision | Diamond | `diam` | Decision-making step | `decision`, `diamond`, `question` |
6dd74de339| Delay | Half-Rounded Rectangle | `delay` | Represents a delay | `half-rounded-rectangle` |
6dd74de340| Direct Access Storage | Horizontal Cylinder | `h-cyl` | Direct access storage | `das`, `horizontal-cylinder` |
6dd74de341| Disk Storage | Lined Cylinder | `lin-cyl` | Disk storage | `disk`, `lined-cylinder` |
6dd74de342| Display | Curved Trapezoid | `curv-trap` | Represents a display | `curved-trapezoid`, `display` |
6dd74de343| Divided Process | Divided Rectangle | `div-rect` | Divided process shape | `div-proc`, `divided-process`, `divided-rectangle` |
6dd74de344| Document | Document | `doc` | Represents a document | `doc`, `document` |
6dd74de345| Event | Rounded Rectangle | `rounded` | Represents an event | `event` |
6dd74de346| Extract | Triangle | `tri` | Extraction process | `extract`, `triangle` |
6dd74de347| Fork/Join | Filled Rectangle | `fork` | Fork or join in process flow | `join` |
6dd74de348| Internal Storage | Window Pane | `win-pane` | Internal storage | `internal-storage`, `window-pane` |
6dd74de349| Junction | Filled Circle | `f-circ` | Junction point | `filled-circle`, `junction` |
6dd74de350| Lined Document | Lined Document | `lin-doc` | Lined document | `lined-document` |
6dd74de351| Lined/Shaded Process | Lined Rectangle | `lin-rect` | Lined process shape | `lin-proc`, `lined-process`, `lined-rectangle`, `shaded-process` |
6dd74de352| Loop Limit | Trapezoidal Pentagon | `notch-pent` | Loop limit step | `loop-limit`, `notched-pentagon` |
6dd74de353| Manual File | Flipped Triangle | `flip-tri` | Manual file operation | `flipped-triangle`, `manual-file` |
6dd74de354| Manual Input | Sloped Rectangle | `sl-rect` | Manual input step | `manual-input`, `sloped-rectangle` |
6dd74de355| Manual Operation | Trapezoid Base Top | `trap-t` | Represents a manual task | `inv-trapezoid`, `manual`, `trapezoid-top` |
6dd74de356| Multi-Document | Stacked Document | `docs` | Multiple documents | `documents`, `st-doc`, `stacked-document` |
6dd74de357| Multi-Process | Stacked Rectangle | `st-rect` | Multiple processes | `processes`, `procs`, `stacked-rectangle` |
6dd74de358| Odd | Odd | `odd` | Odd shape | |
6dd74de359| Paper Tape | Flag | `flag` | Paper tape | `paper-tape` |
6dd74de360| Prepare Conditional | Hexagon | `hex` | Preparation or condition step | `hexagon`, `prepare` |
6dd74de361| Priority Action | Trapezoid Base Bottom | `trap-b` | Priority action | `priority`, `trapezoid`, `trapezoid-bottom` |
6dd74de362| Process | Rectangle | `rect` | Standard process shape | `proc`, `process`, `rectangle` |
6dd74de363| Start | Circle | `circle` | Starting point | `circ` |
6dd74de364| Start | Small Circle | `sm-circ` | Small starting point | `small-circle`, `start` |
6dd74de365| Stop | Double Circle | `dbl-circ` | Represents a stop point | `double-circle` |
6dd74de366| Stop | Framed Circle | `fr-circ` | Stop point | `framed-circle`, `stop` |
6dd74de367| Stored Data | Bow Tie Rectangle | `bow-rect` | Stored data | `bow-tie-rectangle`, `stored-data` |
6dd74de368| Subprocess | Framed Rectangle | `fr-rect` | Subprocess | `framed-rectangle`, `subproc`, `subprocess`, `subroutine` |
6dd74de369| Summary | Crossed Circle | `cross-circ` | Summary | `crossed-circle`, `summary` |
6dd74de370| Tagged Document | Tagged Document | `tag-doc` | Tagged document | `tag-doc`, `tagged-document` |
6dd74de371| Tagged Process | Tagged Rectangle | `tag-rect` | Tagged process | `tag-proc`, `tagged-process`, `tagged-rectangle` |
6dd74de372| Terminal Point | Stadium | `stadium` | Terminal point | `pill`, `terminal` |
6dd74de373| Text Block | Text Block | `text` | Text block | |
6dd74de374
6dd74de375### Example Flowchart with New Shapes
6dd74de376
6dd74de377Here’s an example flowchart that utilizes some of the newly introduced shapes:
6dd74de378
6dd74de379```mermaid-example
6dd74de380flowchart RL
6dd74de381 A@{ shape: manual-file, label: "File Handling"}
6dd74de382 B@{ shape: manual-input, label: "User Input"}
6dd74de383 C@{ shape: docs, label: "Multiple Documents"}
6dd74de384 D@{ shape: procs, label: "Process Automation"}
6dd74de385 E@{ shape: paper-tape, label: "Paper Records"}
6dd74de386```
6dd74de387
6dd74de388```mermaid
6dd74de389flowchart RL
6dd74de390 A@{ shape: manual-file, label: "File Handling"}
6dd74de391 B@{ shape: manual-input, label: "User Input"}
6dd74de392 C@{ shape: docs, label: "Multiple Documents"}
6dd74de393 D@{ shape: procs, label: "Process Automation"}
6dd74de394 E@{ shape: paper-tape, label: "Paper Records"}
6dd74de395```
6dd74de396
6dd74de397### Process
6dd74de398
6dd74de399```mermaid-example
6dd74de400flowchart TD
6dd74de401 A@{ shape: rect, label: "This is a process" }
6dd74de402```
6dd74de403
6dd74de404```mermaid
6dd74de405flowchart TD
6dd74de406 A@{ shape: rect, label: "This is a process" }
6dd74de407```
6dd74de408
6dd74de409### Event
6dd74de410
6dd74de411```mermaid-example
6dd74de412flowchart TD
6dd74de413 A@{ shape: rounded, label: "This is an event" }
6dd74de414```
6dd74de415
6dd74de416```mermaid
6dd74de417flowchart TD
6dd74de418 A@{ shape: rounded, label: "This is an event" }
6dd74de419```
6dd74de420
6dd74de421### Terminal Point (Stadium)
6dd74de422
6dd74de423```mermaid-example
6dd74de424flowchart TD
6dd74de425 A@{ shape: stadium, label: "Terminal point" }
6dd74de426```
6dd74de427
6dd74de428```mermaid
6dd74de429flowchart TD
6dd74de430 A@{ shape: stadium, label: "Terminal point" }
6dd74de431```
6dd74de432
6dd74de433### Subprocess
6dd74de434
6dd74de435```mermaid-example
6dd74de436flowchart TD
6dd74de437 A@{ shape: subproc, label: "This is a subprocess" }
6dd74de438```
6dd74de439
6dd74de440```mermaid
6dd74de441flowchart TD
6dd74de442 A@{ shape: subproc, label: "This is a subprocess" }
6dd74de443```
6dd74de444
6dd74de445### Database (Cylinder)
6dd74de446
6dd74de447```mermaid-example
6dd74de448flowchart TD
6dd74de449 A@{ shape: cyl, label: "Database" }
6dd74de450```
6dd74de451
6dd74de452```mermaid
6dd74de453flowchart TD
6dd74de454 A@{ shape: cyl, label: "Database" }
6dd74de455```
6dd74de456
6dd74de457### Start (Circle)
6dd74de458
6dd74de459```mermaid-example
6dd74de460flowchart TD
6dd74de461 A@{ shape: circle, label: "Start" }
6dd74de462```
6dd74de463
6dd74de464```mermaid
6dd74de465flowchart TD
6dd74de466 A@{ shape: circle, label: "Start" }
6dd74de467```
6dd74de468
6dd74de469### Odd
6dd74de470
6dd74de471```mermaid-example
6dd74de472flowchart TD
6dd74de473 A@{ shape: odd, label: "Odd shape" }
6dd74de474```
6dd74de475
6dd74de476```mermaid
6dd74de477flowchart TD
6dd74de478 A@{ shape: odd, label: "Odd shape" }
6dd74de479```
6dd74de480
6dd74de481### Decision (Diamond)
6dd74de482
6dd74de483```mermaid-example
6dd74de484flowchart TD
6dd74de485 A@{ shape: diamond, label: "Decision" }
6dd74de486```
6dd74de487
6dd74de488```mermaid
6dd74de489flowchart TD
6dd74de490 A@{ shape: diamond, label: "Decision" }
6dd74de491```
6dd74de492
6dd74de493### Prepare Conditional (Hexagon)
6dd74de494
6dd74de495```mermaid-example
6dd74de496flowchart TD
6dd74de497 A@{ shape: hex, label: "Prepare conditional" }
6dd74de498```
6dd74de499
6dd74de500```mermaid
6dd74de501flowchart TD
6dd74de502 A@{ shape: hex, label: "Prepare conditional" }
6dd74de503```
6dd74de504
6dd74de505### Data Input/Output (Lean Right)
6dd74de506
6dd74de507```mermaid-example
6dd74de508flowchart TD
6dd74de509 A@{ shape: lean-r, label: "Input/Output" }
6dd74de510```
6dd74de511
6dd74de512```mermaid
6dd74de513flowchart TD
6dd74de514 A@{ shape: lean-r, label: "Input/Output" }
6dd74de515```
6dd74de516
6dd74de517### Data Input/Output (Lean Left)
6dd74de518
6dd74de519```mermaid-example
6dd74de520flowchart TD
6dd74de521 A@{ shape: lean-l, label: "Output/Input" }
6dd74de522```
6dd74de523
6dd74de524```mermaid
6dd74de525flowchart TD
6dd74de526 A@{ shape: lean-l, label: "Output/Input" }
6dd74de527```
6dd74de528
6dd74de529### Priority Action (Trapezoid Base Bottom)
6dd74de530
6dd74de531```mermaid-example
6dd74de532flowchart TD
6dd74de533 A@{ shape: trap-b, label: "Priority action" }
6dd74de534```
6dd74de535
6dd74de536```mermaid
6dd74de537flowchart TD
6dd74de538 A@{ shape: trap-b, label: "Priority action" }
6dd74de539```
6dd74de540
6dd74de541### Manual Operation (Trapezoid Base Top)
6dd74de542
6dd74de543```mermaid-example
6dd74de544flowchart TD
6dd74de545 A@{ shape: trap-t, label: "Manual operation" }
6dd74de546```
6dd74de547
6dd74de548```mermaid
6dd74de549flowchart TD
6dd74de550 A@{ shape: trap-t, label: "Manual operation" }
6dd74de551```
6dd74de552
6dd74de553### Stop (Double Circle)
6dd74de554
6dd74de555```mermaid-example
6dd74de556flowchart TD
6dd74de557 A@{ shape: dbl-circ, label: "Stop" }
6dd74de558```
6dd74de559
6dd74de560```mermaid
6dd74de561flowchart TD
6dd74de562 A@{ shape: dbl-circ, label: "Stop" }
6dd74de563```
6dd74de564
6dd74de565### Text Block
6dd74de566
6dd74de567```mermaid-example
6dd74de568flowchart TD
6dd74de569 A@{ shape: text, label: "This is a text block" }
6dd74de570```
6dd74de571
6dd74de572```mermaid
6dd74de573flowchart TD
6dd74de574 A@{ shape: text, label: "This is a text block" }
6dd74de575```
6dd74de576
6dd74de577### Card (Notched Rectangle)
6dd74de578
6dd74de579```mermaid-example
6dd74de580flowchart TD
6dd74de581 A@{ shape: notch-rect, label: "Card" }
6dd74de582```
6dd74de583
6dd74de584```mermaid
6dd74de585flowchart TD
6dd74de586 A@{ shape: notch-rect, label: "Card" }
6dd74de587```
6dd74de588
6dd74de589### Lined/Shaded Process
6dd74de590
6dd74de591```mermaid-example
6dd74de592flowchart TD
6dd74de593 A@{ shape: lin-rect, label: "Lined process" }
6dd74de594```
6dd74de595
6dd74de596```mermaid
6dd74de597flowchart TD
6dd74de598 A@{ shape: lin-rect, label: "Lined process" }
6dd74de599```
6dd74de600
6dd74de601### Start (Small Circle)
6dd74de602
6dd74de603```mermaid-example
6dd74de604flowchart TD
6dd74de605 A@{ shape: sm-circ, label: "Small start" }
6dd74de606```
6dd74de607
6dd74de608```mermaid
6dd74de609flowchart TD
6dd74de610 A@{ shape: sm-circ, label: "Small start" }
6dd74de611```
6dd74de612
6dd74de613### Stop (Framed Circle)
6dd74de614
6dd74de615```mermaid-example
6dd74de616flowchart TD
6dd74de617 A@{ shape: framed-circle, label: "Stop" }
6dd74de618```
6dd74de619
6dd74de620```mermaid
6dd74de621flowchart TD
6dd74de622 A@{ shape: framed-circle, label: "Stop" }
6dd74de623```
6dd74de624
6dd74de625### Fork/Join (Long Rectangle)
6dd74de626
6dd74de627```mermaid-example
6dd74de628flowchart TD
6dd74de629 A@{ shape: fork, label: "Fork or Join" }
6dd74de630```
6dd74de631
6dd74de632```mermaid
6dd74de633flowchart TD
6dd74de634 A@{ shape: fork, label: "Fork or Join" }
6dd74de635```
6dd74de636
6dd74de637### Collate (Hourglass)
6dd74de638
6dd74de639```mermaid-example
6dd74de640flowchart TD
6dd74de641 A@{ shape: hourglass, label: "Collate" }
6dd74de642```
6dd74de643
6dd74de644```mermaid
6dd74de645flowchart TD
6dd74de646 A@{ shape: hourglass, label: "Collate" }
6dd74de647```
6dd74de648
6dd74de649### Comment (Curly Brace)
6dd74de650
6dd74de651```mermaid-example
6dd74de652flowchart TD
6dd74de653 A@{ shape: comment, label: "Comment" }
6dd74de654```
6dd74de655
6dd74de656```mermaid
6dd74de657flowchart TD
6dd74de658 A@{ shape: comment, label: "Comment" }
6dd74de659```
6dd74de660
6dd74de661### Comment Right (Curly Brace Right)
6dd74de662
6dd74de663```mermaid-example
6dd74de664flowchart TD
6dd74de665 A@{ shape: brace-r, label: "Comment" }
6dd74de666```
6dd74de667
6dd74de668```mermaid
6dd74de669flowchart TD
6dd74de670 A@{ shape: brace-r, label: "Comment" }
6dd74de671```
6dd74de672
6dd74de673### Comment with braces on both sides
6dd74de674
6dd74de675```mermaid-example
6dd74de676flowchart TD
6dd74de677 A@{ shape: braces, label: "Comment" }
6dd74de678```
6dd74de679
6dd74de680```mermaid
6dd74de681flowchart TD
6dd74de682 A@{ shape: braces, label: "Comment" }
6dd74de683```
6dd74de684
6dd74de685### Com Link (Lightning Bolt)
6dd74de686
6dd74de687```mermaid-example
6dd74de688flowchart TD
6dd74de689 A@{ shape: bolt, label: "Communication link" }
6dd74de690```
6dd74de691
6dd74de692```mermaid
6dd74de693flowchart TD
6dd74de694 A@{ shape: bolt, label: "Communication link" }
6dd74de695```
6dd74de696
6dd74de697### Document
6dd74de698
6dd74de699```mermaid-example
6dd74de700flowchart TD
6dd74de701 A@{ shape: doc, label: "Document" }
6dd74de702```
6dd74de703
6dd74de704```mermaid
6dd74de705flowchart TD
6dd74de706 A@{ shape: doc, label: "Document" }
6dd74de707```
6dd74de708
6dd74de709### Delay (Half-Rounded Rectangle)
6dd74de710
6dd74de711```mermaid-example
6dd74de712flowchart TD
6dd74de713 A@{ shape: delay, label: "Delay" }
6dd74de714```
6dd74de715
6dd74de716```mermaid
6dd74de717flowchart TD
6dd74de718 A@{ shape: delay, label: "Delay" }
6dd74de719```
6dd74de720
6dd74de721### Direct Access Storage (Horizontal Cylinder)
6dd74de722
6dd74de723```mermaid-example
6dd74de724flowchart TD
6dd74de725 A@{ shape: das, label: "Direct access storage" }
6dd74de726```
6dd74de727
6dd74de728```mermaid
6dd74de729flowchart TD
6dd74de730 A@{ shape: das, label: "Direct access storage" }
6dd74de731```
6dd74de732
6dd74de733### Disk Storage (Lined Cylinder)
6dd74de734
6dd74de735```mermaid-example
6dd74de736flowchart TD
6dd74de737 A@{ shape: lin-cyl, label: "Disk storage" }
6dd74de738```
6dd74de739
6dd74de740```mermaid
6dd74de741flowchart TD
6dd74de742 A@{ shape: lin-cyl, label: "Disk storage" }
6dd74de743```
6dd74de744
6dd74de745### Display (Curved Trapezoid)
6dd74de746
6dd74de747```mermaid-example
6dd74de748flowchart TD
6dd74de749 A@{ shape: curv-trap, label: "Display" }
6dd74de750```
6dd74de751
6dd74de752```mermaid
6dd74de753flowchart TD
6dd74de754 A@{ shape: curv-trap, label: "Display" }
6dd74de755```
6dd74de756
6dd74de757### Divided Process (Divided Rectangle)
6dd74de758
6dd74de759```mermaid-example
6dd74de760flowchart TD
6dd74de761 A@{ shape: div-rect, label: "Divided process" }
6dd74de762```
6dd74de763
6dd74de764```mermaid
6dd74de765flowchart TD
6dd74de766 A@{ shape: div-rect, label: "Divided process" }
6dd74de767```
6dd74de768
6dd74de769### Extract (Small Triangle)
6dd74de770
6dd74de771```mermaid-example
6dd74de772flowchart TD
6dd74de773 A@{ shape: tri, label: "Extract" }
6dd74de774```
6dd74de775
6dd74de776```mermaid
6dd74de777flowchart TD
6dd74de778 A@{ shape: tri, label: "Extract" }
6dd74de779```
6dd74de780
6dd74de781### Internal Storage (Window Pane)
6dd74de782
6dd74de783```mermaid-example
6dd74de784flowchart TD
6dd74de785 A@{ shape: win-pane, label: "Internal storage" }
6dd74de786```
6dd74de787
6dd74de788```mermaid
6dd74de789flowchart TD
6dd74de790 A@{ shape: win-pane, label: "Internal storage" }
6dd74de791```
6dd74de792
6dd74de793### Junction (Filled Circle)
6dd74de794
6dd74de795```mermaid-example
6dd74de796flowchart TD
6dd74de797 A@{ shape: f-circ, label: "Junction" }
6dd74de798```
6dd74de799
6dd74de800```mermaid
6dd74de801flowchart TD
6dd74de802 A@{ shape: f-circ, label: "Junction" }
6dd74de803```
6dd74de804
6dd74de805### Lined Document
6dd74de806
6dd74de807```mermaid-example
6dd74de808flowchart TD
6dd74de809 A@{ shape: lin-doc, label: "Lined document" }
6dd74de810```
6dd74de811
6dd74de812```mermaid
6dd74de813flowchart TD
6dd74de814 A@{ shape: lin-doc, label: "Lined document" }
6dd74de815```
6dd74de816
6dd74de817### Loop Limit (Notched Pentagon)
6dd74de818
6dd74de819```mermaid-example
6dd74de820flowchart TD
6dd74de821 A@{ shape: notch-pent, label: "Loop limit" }
6dd74de822```
6dd74de823
6dd74de824```mermaid
6dd74de825flowchart TD
6dd74de826 A@{ shape: notch-pent, label: "Loop limit" }
6dd74de827```
6dd74de828
6dd74de829### Manual File (Flipped Triangle)
6dd74de830
6dd74de831```mermaid-example
6dd74de832flowchart TD
6dd74de833 A@{ shape: flip-tri, label: "Manual file" }
6dd74de834```
6dd74de835
6dd74de836```mermaid
6dd74de837flowchart TD
6dd74de838 A@{ shape: flip-tri, label: "Manual file" }
6dd74de839```
6dd74de840
6dd74de841### Manual Input (Sloped Rectangle)
6dd74de842
6dd74de843```mermaid-example
6dd74de844flowchart TD
6dd74de845 A@{ shape: sl-rect, label: "Manual input" }
6dd74de846```
6dd74de847
6dd74de848```mermaid
6dd74de849flowchart TD
6dd74de850 A@{ shape: sl-rect, label: "Manual input" }
6dd74de851```
6dd74de852
6dd74de853### Multi-Document (Stacked Document)
6dd74de854
6dd74de855```mermaid-example
6dd74de856flowchart TD
6dd74de857 A@{ shape: docs, label: "Multiple documents" }
6dd74de858```
6dd74de859
6dd74de860```mermaid
6dd74de861flowchart TD
6dd74de862 A@{ shape: docs, label: "Multiple documents" }
6dd74de863```
6dd74de864
6dd74de865### Multi-Process (Stacked Rectangle)
6dd74de866
6dd74de867```mermaid-example
6dd74de868flowchart TD
6dd74de869 A@{ shape: processes, label: "Multiple processes" }
6dd74de870```
6dd74de871
6dd74de872```mermaid
6dd74de873flowchart TD
6dd74de874 A@{ shape: processes, label: "Multiple processes" }
6dd74de875```
6dd74de876
6dd74de877### Paper Tape (Flag)
6dd74de878
6dd74de879```mermaid-example
6dd74de880flowchart TD
6dd74de881 A@{ shape: flag, label: "Paper tape" }
6dd74de882```
6dd74de883
6dd74de884```mermaid
6dd74de885flowchart TD
6dd74de886 A@{ shape: flag, label: "Paper tape" }
6dd74de887```
6dd74de888
6dd74de889### Stored Data (Bow Tie Rectangle)
6dd74de890
6dd74de891```mermaid-example
6dd74de892flowchart TD
6dd74de893 A@{ shape: bow-rect, label: "Stored data" }
6dd74de894```
6dd74de895
6dd74de896```mermaid
6dd74de897flowchart TD
6dd74de898 A@{ shape: bow-rect, label: "Stored data" }
6dd74de899```
6dd74de900
6dd74de901### Summary (Crossed Circle)
6dd74de902
6dd74de903```mermaid-example
6dd74de904flowchart TD
6dd74de905 A@{ shape: cross-circ, label: "Summary" }
6dd74de906```
6dd74de907
6dd74de908```mermaid
6dd74de909flowchart TD
6dd74de910 A@{ shape: cross-circ, label: "Summary" }
6dd74de911```
6dd74de912
6dd74de913### Tagged Document
6dd74de914
6dd74de915```mermaid-example
6dd74de916flowchart TD
6dd74de917 A@{ shape: tag-doc, label: "Tagged document" }
6dd74de918```
6dd74de919
6dd74de920```mermaid
6dd74de921flowchart TD
6dd74de922 A@{ shape: tag-doc, label: "Tagged document" }
6dd74de923```
6dd74de924
6dd74de925### Tagged Process (Tagged Rectangle)
6dd74de926
6dd74de927```mermaid-example
6dd74de928flowchart TD
6dd74de929 A@{ shape: tag-rect, label: "Tagged process" }
6dd74de930```
6dd74de931
6dd74de932```mermaid
6dd74de933flowchart TD
6dd74de934 A@{ shape: tag-rect, label: "Tagged process" }
6dd74de935```
6dd74de936
6dd74de937## Special shapes in Mermaid Flowcharts (v11.3.0+)
6dd74de938
6dd74de939Mermaid also introduces 2 special shapes to enhance your flowcharts: **icon** and **image**. These shapes allow you to include icons and images directly within your flowcharts, providing more visual context and clarity.
6dd74de940
6dd74de941### Icon Shape
6dd74de942
6dd74de943You can use the `icon` shape to include an icon in your flowchart. To use icons, you need to register the icon pack first. Follow the instructions to [add custom icons](../config/icons.md). The syntax for defining an icon shape is as follows:
6dd74de944
6dd74de945```mermaid-example
6dd74de946flowchart TD
6dd74de947 A@{ icon: "fa:user", form: "square", label: "User Icon", pos: "t", h: 60 }
6dd74de948```
6dd74de949
6dd74de950```mermaid
6dd74de951flowchart TD
6dd74de952 A@{ icon: "fa:user", form: "square", label: "User Icon", pos: "t", h: 60 }
6dd74de953```
6dd74de954
6dd74de955#### Parameters
6dd74de956
6dd74de957- **icon**: The name of the icon from the registered icon pack.
6dd74de958- **form**: Specifies the background shape of the icon. If not defined there will be no background to icon. Options include:
6dd74de959 - `square`
6dd74de960 - `circle`
6dd74de961 - `rounded`
6dd74de962- **label**: The text label associated with the icon. This can be any string. If not defined, no label will be displayed.
6dd74de963- **pos**: The position of the label. If not defined label will default to bottom of icon. Possible values are:
6dd74de964 - `t`
6dd74de965 - `b`
6dd74de966- **h**: The height of the icon. If not defined this will default to 48 which is minimum.
6dd74de967
6dd74de968### Image Shape
6dd74de969
6dd74de970You can use the `image` shape to include an image in your flowchart. The syntax for defining an image shape is as follows:
6dd74de971
6dd74de972```
6dd74de973flowchart TD
6dd74de974 A@{ img: "https://example.com/image.png", label: "Image Label", pos: "t", w: 60, h: 60, constraint: "off" }
6dd74de975```
6dd74de976
6dd74de977#### Parameters
6dd74de978
6dd74de979- **img**: The URL of the image to be displayed.
6dd74de980- **label**: The text label associated with the image. This can be any string. If not defined, no label will be displayed.
6dd74de981- **pos**: The position of the label. If not defined, the label will default to the bottom of the image. Possible values are:
6dd74de982 - `t`
6dd74de983 - `b`
6dd74de984- **w**: The width of the image. If not defined, this will default to the natural width of the image.
6dd74de985- **h**: The height of the image. If not defined, this will default to the natural height of the image.
6dd74de986- **constraint**: Determines if the image should constrain the node size. This setting also ensures the image maintains its original aspect ratio, adjusting the width (`w`) accordingly to the height (`h`). If not defined, this will default to `off` Possible values are:
6dd74de987 - `on`
6dd74de988 - `off`
6dd74de989
6dd74de990If you want to resize an image, but keep the same aspect ratio, set `h`, and set `constraint: on` to constrain the aspect ratio. E.g.
6dd74de991
6dd74de992```mermaid-example
6dd74de993flowchart TD
6dd74de994 %% My image with a constrained aspect ratio
6dd74de995 A@{ img: "https://mermaid.js.org/favicon.svg", label: "My example image label", pos: "t", h: 60, constraint: "on" }
6dd74de996```
6dd74de997
6dd74de998```mermaid
6dd74de999flowchart TD
6dd74de1000 %% My image with a constrained aspect ratio
6dd74de1001 A@{ img: "https://mermaid.js.org/favicon.svg", label: "My example image label", pos: "t", h: 60, constraint: "on" }
6dd74de1002```
6dd74de1003
6dd74de1004## Links between nodes
6dd74de1005
6dd74de1006Nodes can be connected with links/edges. It is possible to have different types of links or attach a text string to a link.
6dd74de1007
6dd74de1008### A link with arrow head
6dd74de1009
6dd74de1010```mermaid-example
6dd74de1011flowchart LR
6dd74de1012 A-->B
6dd74de1013```
6dd74de1014
6dd74de1015```mermaid
6dd74de1016flowchart LR
6dd74de1017 A-->B
6dd74de1018```
6dd74de1019
6dd74de1020### An open link
6dd74de1021
6dd74de1022```mermaid-example
6dd74de1023flowchart LR
6dd74de1024 A --- B
6dd74de1025```
6dd74de1026
6dd74de1027```mermaid
6dd74de1028flowchart LR
6dd74de1029 A --- B
6dd74de1030```
6dd74de1031
6dd74de1032### Text on links
6dd74de1033
6dd74de1034```mermaid-example
6dd74de1035flowchart LR
6dd74de1036 A-- This is the text! ---B
6dd74de1037```
6dd74de1038
6dd74de1039```mermaid
6dd74de1040flowchart LR
6dd74de1041 A-- This is the text! ---B
6dd74de1042```
6dd74de1043
6dd74de1044or
6dd74de1045
6dd74de1046```mermaid-example
6dd74de1047flowchart LR
6dd74de1048 A---|This is the text|B
6dd74de1049```
6dd74de1050
6dd74de1051```mermaid
6dd74de1052flowchart LR
6dd74de1053 A---|This is the text|B
6dd74de1054```
6dd74de1055
6dd74de1056### A link with arrow head and text
6dd74de1057
6dd74de1058```mermaid-example
6dd74de1059flowchart LR
6dd74de1060 A-->|text|B
6dd74de1061```
6dd74de1062
6dd74de1063```mermaid
6dd74de1064flowchart LR
6dd74de1065 A-->|text|B
6dd74de1066```
6dd74de1067
6dd74de1068or
6dd74de1069
6dd74de1070```mermaid-example
6dd74de1071flowchart LR
6dd74de1072 A-- text -->B
6dd74de1073```
6dd74de1074
6dd74de1075```mermaid
6dd74de1076flowchart LR
6dd74de1077 A-- text -->B
6dd74de1078```
6dd74de1079
6dd74de1080### Dotted link
6dd74de1081
6dd74de1082```mermaid-example
6dd74de1083flowchart LR
6dd74de1084 A-.->B;
6dd74de1085```
6dd74de1086
6dd74de1087```mermaid
6dd74de1088flowchart LR
6dd74de1089 A-.->B;
6dd74de1090```
6dd74de1091
6dd74de1092### Dotted link with text
6dd74de1093
6dd74de1094```mermaid-example
6dd74de1095flowchart LR
6dd74de1096 A-. text .-> B
6dd74de1097```
6dd74de1098
6dd74de1099```mermaid
6dd74de1100flowchart LR
6dd74de1101 A-. text .-> B
6dd74de1102```
6dd74de1103
6dd74de1104### Thick link
6dd74de1105
6dd74de1106```mermaid-example
6dd74de1107flowchart LR
6dd74de1108 A ==> B
6dd74de1109```
6dd74de1110
6dd74de1111```mermaid
6dd74de1112flowchart LR
6dd74de1113 A ==> B
6dd74de1114```
6dd74de1115
6dd74de1116### Thick link with text
6dd74de1117
6dd74de1118```mermaid-example
6dd74de1119flowchart LR
6dd74de1120 A == text ==> B
6dd74de1121```
6dd74de1122
6dd74de1123```mermaid
6dd74de1124flowchart LR
6dd74de1125 A == text ==> B
6dd74de1126```
6dd74de1127
6dd74de1128### An invisible link
6dd74de1129
6dd74de1130This can be a useful tool in some instances where you want to alter the default positioning of a node.
6dd74de1131
6dd74de1132```mermaid-example
6dd74de1133flowchart LR
6dd74de1134 A ~~~ B
6dd74de1135```
6dd74de1136
6dd74de1137```mermaid
6dd74de1138flowchart LR
6dd74de1139 A ~~~ B
6dd74de1140```
6dd74de1141
6dd74de1142### Chaining of links
6dd74de1143
6dd74de1144It is possible declare many links in the same line as per below:
6dd74de1145
6dd74de1146```mermaid-example
6dd74de1147flowchart LR
6dd74de1148 A -- text --> B -- text2 --> C
6dd74de1149```
6dd74de1150
6dd74de1151```mermaid
6dd74de1152flowchart LR
6dd74de1153 A -- text --> B -- text2 --> C
6dd74de1154```
6dd74de1155
6dd74de1156It is also possible to declare multiple nodes links in the same line as per below:
6dd74de1157
6dd74de1158```mermaid-example
6dd74de1159flowchart LR
6dd74de1160 a --> b & c--> d
6dd74de1161```
6dd74de1162
6dd74de1163```mermaid
6dd74de1164flowchart LR
6dd74de1165 a --> b & c--> d
6dd74de1166```
6dd74de1167
6dd74de1168You can then describe dependencies in a very expressive way. Like the one-liner below:
6dd74de1169
6dd74de1170```mermaid-example
6dd74de1171flowchart TB
6dd74de1172 A & B--> C & D
6dd74de1173```
6dd74de1174
6dd74de1175```mermaid
6dd74de1176flowchart TB
6dd74de1177 A & B--> C & D
6dd74de1178```
6dd74de1179
6dd74de1180If you describe the same diagram using the basic syntax, it will take four lines. A
6dd74de1181word of warning, one could go overboard with this making the flowchart harder to read in
6dd74de1182markdown form. The Swedish word `lagom` comes to mind. It means, not too much and not too little.
6dd74de1183This goes for expressive syntaxes as well.
6dd74de1184
6dd74de1185```mermaid-example
6dd74de1186flowchart TB
6dd74de1187 A --> C
6dd74de1188 A --> D
6dd74de1189 B --> C
6dd74de1190 B --> D
6dd74de1191```
6dd74de1192
6dd74de1193```mermaid
6dd74de1194flowchart TB
6dd74de1195 A --> C
6dd74de1196 A --> D
6dd74de1197 B --> C
6dd74de1198 B --> D
6dd74de1199```
6dd74de1200
6dd74de1201### Attaching an ID to Edges
6dd74de1202
6dd74de1203Mermaid now supports assigning IDs to edges, similar to how IDs and metadata can be attached to nodes. This feature lays the groundwork for more advanced styling, classes, and animation capabilities on edges.
6dd74de1204
6dd74de1205**Syntax:**
6dd74de1206
6dd74de1207To give an edge an ID, prepend the edge syntax with the ID followed by an `@` character. For example:
6dd74de1208
6dd74de1209```mermaid-example
6dd74de1210flowchart LR
6dd74de1211 A e1@--> B
6dd74de1212```
6dd74de1213
6dd74de1214```mermaid
6dd74de1215flowchart LR
6dd74de1216 A e1@--> B
6dd74de1217```
6dd74de1218
6dd74de1219In this example, `e1` is the ID of the edge connecting `A` to `B`. You can then use this ID in later definitions or style statements, just like with nodes.
6dd74de1220
6dd74de1221### Turning an Animation On
6dd74de1222
6dd74de1223Once you have assigned an ID to an edge, you can turn on animations for that edge by defining the edge’s properties:
6dd74de1224
6dd74de1225```mermaid-example
6dd74de1226flowchart LR
6dd74de1227 A e1@==> B
6dd74de1228 e1@{ animate: true }
6dd74de1229```
6dd74de1230
6dd74de1231```mermaid
6dd74de1232flowchart LR
6dd74de1233 A e1@==> B
6dd74de1234 e1@{ animate: true }
6dd74de1235```
6dd74de1236
6dd74de1237This tells Mermaid that the edge `e1` should be animated.
6dd74de1238
6dd74de1239### Selecting Type of Animation
6dd74de1240
6dd74de1241In the initial version, two animation speeds are supported: `fast` and `slow`. Selecting a specific animation type is a shorthand for enabling animation and setting the animation speed in one go.
6dd74de1242
6dd74de1243**Examples:**
6dd74de1244
6dd74de1245```mermaid-example
6dd74de1246flowchart LR
6dd74de1247 A e1@--> B
6dd74de1248 e1@{ animation: fast }
6dd74de1249```
6dd74de1250
6dd74de1251```mermaid
6dd74de1252flowchart LR
6dd74de1253 A e1@--> B
6dd74de1254 e1@{ animation: fast }
6dd74de1255```
6dd74de1256
6dd74de1257This is equivalent to `{ animate: true, animation: fast }`.
6dd74de1258
6dd74de1259### Using classDef Statements for Animations
6dd74de1260
6dd74de1261You can also animate edges by assigning a class to them and then defining animation properties in a `classDef` statement. For example:
6dd74de1262
6dd74de1263```mermaid-example
6dd74de1264flowchart LR
6dd74de1265 A e1@--> B
6dd74de1266 classDef animate stroke-dasharray: 9,5,stroke-dashoffset: 900,animation: dash 25s linear infinite;
6dd74de1267 class e1 animate
6dd74de1268```
6dd74de1269
6dd74de1270```mermaid
6dd74de1271flowchart LR
6dd74de1272 A e1@--> B
6dd74de1273 classDef animate stroke-dasharray: 9,5,stroke-dashoffset: 900,animation: dash 25s linear infinite;
6dd74de1274 class e1 animate
6dd74de1275```
6dd74de1276
6dd74de1277In this snippet:
6dd74de1278
6dd74de1279- `e1@-->` creates an edge with ID `e1`.
6dd74de1280- `classDef animate` defines a class named `animate` with styling and animation properties.
6dd74de1281- `class e1 animate` applies the `animate` class to the edge `e1`.
6dd74de1282
6dd74de1283**Note on Escaping Commas:**
6dd74de1284When setting the `stroke-dasharray` property, remember to escape commas as `\,` since commas are used as delimiters in Mermaid’s style definitions.
6dd74de1285
6dd74de1286## New arrow types
6dd74de1287
6dd74de1288There are new types of arrows supported:
6dd74de1289
6dd74de1290- circle edge
6dd74de1291- cross edge
6dd74de1292
6dd74de1293### Circle edge example
6dd74de1294
6dd74de1295```mermaid-example
6dd74de1296flowchart LR
6dd74de1297 A --o B
6dd74de1298```
6dd74de1299
6dd74de1300```mermaid
6dd74de1301flowchart LR
6dd74de1302 A --o B
6dd74de1303```
6dd74de1304
6dd74de1305### Cross edge example
6dd74de1306
6dd74de1307```mermaid-example
6dd74de1308flowchart LR
6dd74de1309 A --x B
6dd74de1310```
6dd74de1311
6dd74de1312```mermaid
6dd74de1313flowchart LR
6dd74de1314 A --x B
6dd74de1315```
6dd74de1316
6dd74de1317## Multi directional arrows
6dd74de1318
6dd74de1319There is the possibility to use multidirectional arrows.
6dd74de1320
6dd74de1321```mermaid-example
6dd74de1322flowchart LR
6dd74de1323 A o--o B
6dd74de1324 B <--> C
6dd74de1325 C x--x D
6dd74de1326```
6dd74de1327
6dd74de1328```mermaid
6dd74de1329flowchart LR
6dd74de1330 A o--o B
6dd74de1331 B <--> C
6dd74de1332 C x--x D
6dd74de1333```
6dd74de1334
6dd74de1335### Minimum length of a link
6dd74de1336
6dd74de1337Each node in the flowchart is ultimately assigned to a rank in the rendered
6dd74de1338graph, i.e. to a vertical or horizontal level (depending on the flowchart
6dd74de1339orientation), based on the nodes to which it is linked. By default, links
6dd74de1340can span any number of ranks, but you can ask for any link to be longer
6dd74de1341than the others by adding extra dashes in the link definition.
6dd74de1342
6dd74de1343In the following example, two extra dashes are added in the link from node _B_
6dd74de1344to node _E_, so that it spans two more ranks than regular links:
6dd74de1345
6dd74de1346```mermaid-example
6dd74de1347flowchart TD
6dd74de1348 A[Start] --> B{Is it?}
6dd74de1349 B -->|Yes| C[OK]
6dd74de1350 C --> D[Rethink]
6dd74de1351 D --> B
6dd74de1352 B ---->|No| E[End]
6dd74de1353```
6dd74de1354
6dd74de1355```mermaid
6dd74de1356flowchart TD
6dd74de1357 A[Start] --> B{Is it?}
6dd74de1358 B -->|Yes| C[OK]
6dd74de1359 C --> D[Rethink]
6dd74de1360 D --> B
6dd74de1361 B ---->|No| E[End]
6dd74de1362```
6dd74de1363
6dd74de1364> **Note** Links may still be made longer than the requested number of ranks
6dd74de1365> by the rendering engine to accommodate other requests.
6dd74de1366
6dd74de1367When the link label is written in the middle of the link, the extra dashes must
6dd74de1368be added on the right side of the link. The following example is equivalent to
6dd74de1369the previous one:
6dd74de1370
6dd74de1371```mermaid-example
6dd74de1372flowchart TD
6dd74de1373 A[Start] --> B{Is it?}
6dd74de1374 B -- Yes --> C[OK]
6dd74de1375 C --> D[Rethink]
6dd74de1376 D --> B
6dd74de1377 B -- No ----> E[End]
6dd74de1378```
6dd74de1379
6dd74de1380```mermaid
6dd74de1381flowchart TD
6dd74de1382 A[Start] --> B{Is it?}
6dd74de1383 B -- Yes --> C[OK]
6dd74de1384 C --> D[Rethink]
6dd74de1385 D --> B
6dd74de1386 B -- No ----> E[End]
6dd74de1387```
6dd74de1388
6dd74de1389For dotted or thick links, the characters to add are equals signs or dots,
6dd74de1390as summed up in the following table:
6dd74de1391
6dd74de1392| Length | 1 | 2 | 3 |
6dd74de1393| ----------------- | :----: | :-----: | :------: |
6dd74de1394| Normal | `---` | `----` | `-----` |
6dd74de1395| Normal with arrow | `-->` | `--->` | `---->` |
6dd74de1396| Thick | `===` | `====` | `=====` |
6dd74de1397| Thick with arrow | `==>` | `===>` | `====>` |
6dd74de1398| Dotted | `-.-` | `-..-` | `-...-` |
6dd74de1399| Dotted with arrow | `-.->` | `-..->` | `-...->` |
6dd74de1400
6dd74de1401## Special characters that break syntax
6dd74de1402
6dd74de1403It is possible to put text within quotes in order to render more troublesome characters. As in the example below:
6dd74de1404
6dd74de1405```mermaid-example
6dd74de1406flowchart LR
6dd74de1407 id1["This is the (text) in the box"]
6dd74de1408```
6dd74de1409
6dd74de1410```mermaid
6dd74de1411flowchart LR
6dd74de1412 id1["This is the (text) in the box"]
6dd74de1413```
6dd74de1414
6dd74de1415### Entity codes to escape characters
6dd74de1416
6dd74de1417It is possible to escape characters using the syntax exemplified here.
6dd74de1418
6dd74de1419```mermaid-example
6dd74de1420 flowchart LR
6dd74de1421 A["A double quote:#quot;"] --> B["A dec char:#9829;"]
6dd74de1422```
6dd74de1423
6dd74de1424```mermaid
6dd74de1425 flowchart LR
6dd74de1426 A["A double quote:#quot;"] --> B["A dec char:#9829;"]
6dd74de1427```
6dd74de1428
6dd74de1429Numbers given are base 10, so `#` can be encoded as `#35;`. It is also supported to use HTML character names.
6dd74de1430
6dd74de1431## Subgraphs
6dd74de1432
6dd74de1433```
6dd74de1434subgraph title
6dd74de1435 graph definition
6dd74de1436end
6dd74de1437```
6dd74de1438
6dd74de1439An example below:
6dd74de1440
6dd74de1441```mermaid-example
6dd74de1442flowchart TB
6dd74de1443 c1-->a2
6dd74de1444 subgraph one
6dd74de1445 a1-->a2
6dd74de1446 end
6dd74de1447 subgraph two
6dd74de1448 b1-->b2
6dd74de1449 end
6dd74de1450 subgraph three
6dd74de1451 c1-->c2
6dd74de1452 end
6dd74de1453```
6dd74de1454
6dd74de1455```mermaid
6dd74de1456flowchart TB
6dd74de1457 c1-->a2
6dd74de1458 subgraph one
6dd74de1459 a1-->a2
6dd74de1460 end
6dd74de1461 subgraph two
6dd74de1462 b1-->b2
6dd74de1463 end
6dd74de1464 subgraph three
6dd74de1465 c1-->c2
6dd74de1466 end
6dd74de1467```
6dd74de1468
6dd74de1469You can also set an explicit id for the subgraph.
6dd74de1470
6dd74de1471```mermaid-example
6dd74de1472flowchart TB
6dd74de1473 c1-->a2
6dd74de1474 subgraph ide1 [one]
6dd74de1475 a1-->a2
6dd74de1476 end
6dd74de1477```
6dd74de1478
6dd74de1479```mermaid
6dd74de1480flowchart TB
6dd74de1481 c1-->a2
6dd74de1482 subgraph ide1 [one]
6dd74de1483 a1-->a2
6dd74de1484 end
6dd74de1485```
6dd74de1486
6dd74de1487### flowcharts
6dd74de1488
6dd74de1489With the graphtype flowchart it is also possible to set edges to and from subgraphs as in the flowchart below.
6dd74de1490
6dd74de1491```mermaid-example
6dd74de1492flowchart TB
6dd74de1493 c1-->a2
6dd74de1494 subgraph one
6dd74de1495 a1-->a2
6dd74de1496 end
6dd74de1497 subgraph two
6dd74de1498 b1-->b2
6dd74de1499 end
6dd74de1500 subgraph three
6dd74de1501 c1-->c2
6dd74de1502 end
6dd74de1503 one --> two
6dd74de1504 three --> two
6dd74de1505 two --> c2
6dd74de1506```
6dd74de1507
6dd74de1508```mermaid
6dd74de1509flowchart TB
6dd74de1510 c1-->a2
6dd74de1511 subgraph one
6dd74de1512 a1-->a2
6dd74de1513 end
6dd74de1514 subgraph two
6dd74de1515 b1-->b2
6dd74de1516 end
6dd74de1517 subgraph three
6dd74de1518 c1-->c2
6dd74de1519 end
6dd74de1520 one --> two
6dd74de1521 three --> two
6dd74de1522 two --> c2
6dd74de1523```
6dd74de1524
6dd74de1525### Direction in subgraphs
6dd74de1526
6dd74de1527With the graphtype flowcharts you can use the direction statement to set the direction which the subgraph will render like in this example.
6dd74de1528
6dd74de1529```mermaid-example
6dd74de1530flowchart LR
6dd74de1531 subgraph TOP
6dd74de1532 direction TB
6dd74de1533 subgraph B1
6dd74de1534 direction RL
6dd74de1535 i1 -->f1
6dd74de1536 end
6dd74de1537 subgraph B2
6dd74de1538 direction BT
6dd74de1539 i2 -->f2
6dd74de1540 end
6dd74de1541 end
6dd74de1542 A --> TOP --> B
6dd74de1543 B1 --> B2
6dd74de1544```
6dd74de1545
6dd74de1546```mermaid
6dd74de1547flowchart LR
6dd74de1548 subgraph TOP
6dd74de1549 direction TB
6dd74de1550 subgraph B1
6dd74de1551 direction RL
6dd74de1552 i1 -->f1
6dd74de1553 end
6dd74de1554 subgraph B2
6dd74de1555 direction BT
6dd74de1556 i2 -->f2
6dd74de1557 end
6dd74de1558 end
6dd74de1559 A --> TOP --> B
6dd74de1560 B1 --> B2
6dd74de1561```
6dd74de1562
6dd74de1563#### Limitation
6dd74de1564
6dd74de1565If any of a subgraph's nodes are linked to the outside, subgraph direction will be ignored. Instead the subgraph will inherit the direction of the parent graph:
6dd74de1566
6dd74de1567```mermaid-example
6dd74de1568flowchart LR
6dd74de1569 subgraph subgraph1
6dd74de1570 direction TB
6dd74de1571 top1[top] --> bottom1[bottom]
6dd74de1572 end
6dd74de1573 subgraph subgraph2
6dd74de1574 direction TB
6dd74de1575 top2[top] --> bottom2[bottom]
6dd74de1576 end
6dd74de1577 %% ^ These subgraphs are identical, except for the links to them:
6dd74de1578
6dd74de1579 %% Link *to* subgraph1: subgraph1 direction is maintained
6dd74de1580 outside --> subgraph1
6dd74de1581 %% Link *within* subgraph2:
6dd74de1582 %% subgraph2 inherits the direction of the top-level graph (LR)
6dd74de1583 outside ---> top2
6dd74de1584```
6dd74de1585
6dd74de1586```mermaid
6dd74de1587flowchart LR
6dd74de1588 subgraph subgraph1
6dd74de1589 direction TB
6dd74de1590 top1[top] --> bottom1[bottom]
6dd74de1591 end
6dd74de1592 subgraph subgraph2
6dd74de1593 direction TB
6dd74de1594 top2[top] --> bottom2[bottom]
6dd74de1595 end
6dd74de1596 %% ^ These subgraphs are identical, except for the links to them:
6dd74de1597
6dd74de1598 %% Link *to* subgraph1: subgraph1 direction is maintained
6dd74de1599 outside --> subgraph1
6dd74de1600 %% Link *within* subgraph2:
6dd74de1601 %% subgraph2 inherits the direction of the top-level graph (LR)
6dd74de1602 outside ---> top2
6dd74de1603```
6dd74de1604
6dd74de1605## Markdown Strings
6dd74de1606
6dd74de1607The "Markdown Strings" feature enhances flowcharts and mind maps by offering a more versatile string type, which supports text formatting options such as bold and italics, and automatically wraps text within labels.
6dd74de1608
6dd74de1609```mermaid-example
6dd74de1610---
6dd74de1611config:
6dd74de1612 htmlLabels: false
6dd74de1613---
6dd74de1614flowchart LR
6dd74de1615subgraph "One"
6dd74de1616 a("`The **cat**
6dd74de1617 in the hat`") -- "edge label" --> b{{"`The **dog** in the hog`"}}
6dd74de1618end
6dd74de1619subgraph "`**Two**`"
6dd74de1620 c("`The **cat**
6dd74de1621 in the hat`") -- "`Bold **edge label**`" --> d("The dog in the hog")
6dd74de1622end
6dd74de1623```
6dd74de1624
6dd74de1625```mermaid
6dd74de1626---
6dd74de1627config:
6dd74de1628 htmlLabels: false
6dd74de1629---
6dd74de1630flowchart LR
6dd74de1631subgraph "One"
6dd74de1632 a("`The **cat**
6dd74de1633 in the hat`") -- "edge label" --> b{{"`The **dog** in the hog`"}}
6dd74de1634end
6dd74de1635subgraph "`**Two**`"
6dd74de1636 c("`The **cat**
6dd74de1637 in the hat`") -- "`Bold **edge label**`" --> d("The dog in the hog")
6dd74de1638end
6dd74de1639```
6dd74de1640
6dd74de1641Formatting:
6dd74de1642
6dd74de1643- For bold text, use double asterisks (`**`) before and after the text.
6dd74de1644- For italics, use single asterisks (`*`) before and after the text.
6dd74de1645- With traditional strings, you needed to add `<br>` tags for text to wrap in nodes. However, markdown strings automatically wrap text when it becomes too long and allows you to start a new line by simply using a newline character instead of a `<br>` tag.
6dd74de1646
6dd74de1647This feature is applicable to node labels, edge labels, and subgraph labels.
6dd74de1648
6dd74de1649The auto wrapping can be disabled by using
6dd74de1650
6dd74de1651```
6dd74de1652---
6dd74de1653config:
6dd74de1654 markdownAutoWrap: false
6dd74de1655---
6dd74de1656graph LR
6dd74de1657```
6dd74de1658
6dd74de1659## Interaction
6dd74de1660
6dd74de1661It is possible to bind a click event to a node, the click can lead to either a javascript callback or to a link which will be opened in a new browser tab.
6dd74de1662
6dd74de1663> **Note**
6dd74de1664> This functionality is disabled when using `securityLevel='strict'` and enabled when using `securityLevel='loose'`.
6dd74de1665
6dd74de1666```
6dd74de1667click nodeId callback
6dd74de1668click nodeId call callback()
6dd74de1669```
6dd74de1670
6dd74de1671- nodeId is the id of the node
6dd74de1672- callback is the name of a javascript function defined on the page displaying the graph, the function will be called with the nodeId as parameter.
6dd74de1673
6dd74de1674Examples of tooltip usage below:
6dd74de1675
6dd74de1676```html
6dd74de1677<script>
6dd74de1678 window.callback = function () {
6dd74de1679 alert('A callback was triggered');
6dd74de1680 };
6dd74de1681</script>
6dd74de1682```
6dd74de1683
6dd74de1684The tooltip text is surrounded in double quotes. The styles of the tooltip are set by the class `.mermaidTooltip`.
6dd74de1685
6dd74de1686```mermaid-example
6dd74de1687flowchart LR
6dd74de1688 A-->B
6dd74de1689 B-->C
6dd74de1690 C-->D
6dd74de1691 click A callback "Tooltip for a callback"
6dd74de1692 click B "https://www.github.com" "This is a tooltip for a link"
6dd74de1693 click C call callback() "Tooltip for a callback"
6dd74de1694 click D href "https://www.github.com" "This is a tooltip for a link"
6dd74de1695```
6dd74de1696
6dd74de1697```mermaid
6dd74de1698flowchart LR
6dd74de1699 A-->B
6dd74de1700 B-->C
6dd74de1701 C-->D
6dd74de1702 click A callback "Tooltip for a callback"
6dd74de1703 click B "https://www.github.com" "This is a tooltip for a link"
6dd74de1704 click C call callback() "Tooltip for a callback"
6dd74de1705 click D href "https://www.github.com" "This is a tooltip for a link"
6dd74de1706```
6dd74de1707
6dd74de1708> **Success** The tooltip functionality and the ability to link to urls are available from version 0.5.2.
6dd74de1709
6dd74de1710?> Due to limitations with how Docsify handles JavaScript callback functions, an alternate working demo for the above code can be viewed at [this jsfiddle](https://jsfiddle.net/yk4h7qou/2/).
6dd74de1711
6dd74de1712Links are opened in the same browser tab/window by default. It is possible to change this by adding a link target to the click definition (`_self`, `_blank`, `_parent` and `_top` are supported):
6dd74de1713
6dd74de1714```mermaid-example
6dd74de1715flowchart LR
6dd74de1716 A-->B
6dd74de1717 B-->C
6dd74de1718 C-->D
6dd74de1719 D-->E
6dd74de1720 click A "https://www.github.com" _blank
6dd74de1721 click B "https://www.github.com" "Open this in a new tab" _blank
6dd74de1722 click C href "https://www.github.com" _blank
6dd74de1723 click D href "https://www.github.com" "Open this in a new tab" _blank
6dd74de1724```
6dd74de1725
6dd74de1726```mermaid
6dd74de1727flowchart LR
6dd74de1728 A-->B
6dd74de1729 B-->C
6dd74de1730 C-->D
6dd74de1731 D-->E
6dd74de1732 click A "https://www.github.com" _blank
6dd74de1733 click B "https://www.github.com" "Open this in a new tab" _blank
6dd74de1734 click C href "https://www.github.com" _blank
6dd74de1735 click D href "https://www.github.com" "Open this in a new tab" _blank
6dd74de1736```
6dd74de1737
6dd74de1738Beginner's tip—a full example using interactive links in a html context:
6dd74de1739
6dd74de1740```html
6dd74de1741<body>
6dd74de1742 <pre class="mermaid">
6dd74de1743 flowchart LR
6dd74de1744 A-->B
6dd74de1745 B-->C
6dd74de1746 C-->D
6dd74de1747 click A callback "Tooltip"
6dd74de1748 click B "https://www.github.com" "This is a link"
6dd74de1749 click C call callback() "Tooltip"
6dd74de1750 click D href "https://www.github.com" "This is a link"
6dd74de1751 </pre>
6dd74de1752
6dd74de1753 <script>
6dd74de1754 window.callback = function () {
6dd74de1755 alert('A callback was triggered');
6dd74de1756 };
6dd74de1757 const config = {
6dd74de1758 startOnLoad: true,
6dd74de1759 htmlLabels: true,
6dd74de1760 flowchart: { useMaxWidth: true, curve: 'cardinal' },
6dd74de1761 securityLevel: 'loose',
6dd74de1762 };
6dd74de1763 mermaid.initialize(config);
6dd74de1764 </script>
6dd74de1765</body>
6dd74de1766```
6dd74de1767
6dd74de1768### Comments
6dd74de1769
6dd74de1770Comments can be entered within a flow diagram, which will be ignored by the parser. Comments need to be on their own line, and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any flow syntax
6dd74de1771
6dd74de1772```mermaid-example
6dd74de1773flowchart LR
6dd74de1774%% this is a comment A -- text --> B{node}
6dd74de1775 A -- text --> B -- text2 --> C
6dd74de1776```
6dd74de1777
6dd74de1778```mermaid
6dd74de1779flowchart LR
6dd74de1780%% this is a comment A -- text --> B{node}
6dd74de1781 A -- text --> B -- text2 --> C
6dd74de1782```
6dd74de1783
6dd74de1784## Styling and classes
6dd74de1785
6dd74de1786### Styling links
6dd74de1787
6dd74de1788It is possible to style links. For instance, you might want to style a link that is going backwards in the flow. As links
6dd74de1789have no ids in the same way as nodes, some other way of deciding what style the links should be attached to is required.
6dd74de1790Instead of ids, the order number of when the link was defined in the graph is used, or use default to apply to all links.
6dd74de1791In the example below the style defined in the linkStyle statement will belong to the fourth link in the graph:
6dd74de1792
6dd74de1793```
6dd74de1794linkStyle 3 stroke:#ff3,stroke-width:4px,color:red;
6dd74de1795```
6dd74de1796
6dd74de1797It is also possible to add style to multiple links in a single statement, by separating link numbers with commas:
6dd74de1798
6dd74de1799```
6dd74de1800linkStyle 1,2,7 color:blue;
6dd74de1801```
6dd74de1802
6dd74de1803### Styling line curves
6dd74de1804
6dd74de1805It is possible to style the type of curve used for lines between items, if the default method does not meet your needs.
6dd74de1806Available curve styles include `basis`, `bumpX`, `bumpY`, `cardinal`, `catmullRom`, `linear`, `monotoneX`, `monotoneY`,
6dd74de1807`natural`, `step`, `stepAfter`, and `stepBefore`.
6dd74de1808
6dd74de1809For a full list of available curves, including an explanation of custom curves, refer to
6dd74de1810the [Shapes](https://d3js.org/d3-shape/curve) documentation in the [d3-shape](https://github.com/d3/d3-shape/) project.
6dd74de1811
6dd74de1812Line styling can be achieved in two ways:
6dd74de1813
6dd74de18141. Change the curve style of all the lines
6dd74de18152. Change the curve style of a particular line
6dd74de1816
6dd74de1817#### Diagram level curve style
6dd74de1818
6dd74de1819In this example, a left-to-right graph uses the `stepBefore` curve style:
6dd74de1820
6dd74de1821```
6dd74de1822---
6dd74de1823config:
6dd74de1824 flowchart:
6dd74de1825 curve: stepBefore
6dd74de1826---
6dd74de1827graph LR
6dd74de1828```
6dd74de1829
6dd74de1830#### Edge level curve style using Edge IDs (v11.10.0+)
6dd74de1831
6dd74de1832You can assign IDs to [edges](#attaching-an-id-to-edges). After assigning an ID you can modify the line style by modifying the edge's `curve` property using the following syntax:
6dd74de1833
6dd74de1834```mermaid-example
6dd74de1835flowchart LR
6dd74de1836 A e1@==> B
6dd74de1837 A e2@--> C
6dd74de1838 e1@{ curve: linear }
6dd74de1839 e2@{ curve: natural }
6dd74de1840```
6dd74de1841
6dd74de1842```mermaid
6dd74de1843flowchart LR
6dd74de1844 A e1@==> B
6dd74de1845 A e2@--> C
6dd74de1846 e1@{ curve: linear }
6dd74de1847 e2@{ curve: natural }
6dd74de1848```
6dd74de1849
6dd74de1850```info
6dd74de1851Any edge curve style modified at the edge level overrides the diagram level style.
6dd74de1852```
6dd74de1853
6dd74de1854```info
6dd74de1855If the same edge is modified multiple times the last modification will be rendered.
6dd74de1856```
6dd74de1857
6dd74de1858### Styling a node
6dd74de1859
6dd74de1860It is possible to apply specific styles such as a thicker border or a different background color to a node.
6dd74de1861
6dd74de1862```mermaid-example
6dd74de1863flowchart LR
6dd74de1864 id1(Start)-->id2(Stop)
6dd74de1865 style id1 fill:#f9f,stroke:#333,stroke-width:4px
6dd74de1866 style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
6dd74de1867```
6dd74de1868
6dd74de1869```mermaid
6dd74de1870flowchart LR
6dd74de1871 id1(Start)-->id2(Stop)
6dd74de1872 style id1 fill:#f9f,stroke:#333,stroke-width:4px
6dd74de1873 style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
6dd74de1874```
6dd74de1875
6dd74de1876#### Classes
6dd74de1877
6dd74de1878More convenient than defining the style every time is to define a class of styles and attach this class to the nodes that
6dd74de1879should have a different look.
6dd74de1880
6dd74de1881A class definition looks like the example below:
6dd74de1882
6dd74de1883```
6dd74de1884 classDef className fill:#f9f,stroke:#333,stroke-width:4px;
6dd74de1885```
6dd74de1886
6dd74de1887Also, it is possible to define style to multiple classes in one statement:
6dd74de1888
6dd74de1889```
6dd74de1890 classDef firstClassName,secondClassName font-size:12pt;
6dd74de1891```
6dd74de1892
6dd74de1893Attachment of a class to a node is done as per below:
6dd74de1894
6dd74de1895```
6dd74de1896 class nodeId1 className;
6dd74de1897```
6dd74de1898
6dd74de1899It is also possible to attach a class to a list of nodes in one statement:
6dd74de1900
6dd74de1901```
6dd74de1902 class nodeId1,nodeId2 className;
6dd74de1903```
6dd74de1904
6dd74de1905A shorter form of adding a class is to attach the classname to the node using the `:::`operator as per below:
6dd74de1906
6dd74de1907```mermaid-example
6dd74de1908flowchart LR
6dd74de1909 A:::someclass --> B
6dd74de1910 classDef someclass fill:#f96
6dd74de1911```
6dd74de1912
6dd74de1913```mermaid
6dd74de1914flowchart LR
6dd74de1915 A:::someclass --> B
6dd74de1916 classDef someclass fill:#f96
6dd74de1917```
6dd74de1918
6dd74de1919This form can be used when declaring multiple links between nodes:
6dd74de1920
6dd74de1921```mermaid-example
6dd74de1922flowchart LR
6dd74de1923 A:::foo & B:::bar --> C:::foobar
6dd74de1924 classDef foo stroke:#f00
6dd74de1925 classDef bar stroke:#0f0
6dd74de1926 classDef foobar stroke:#00f
6dd74de1927```
6dd74de1928
6dd74de1929```mermaid
6dd74de1930flowchart LR
6dd74de1931 A:::foo & B:::bar --> C:::foobar
6dd74de1932 classDef foo stroke:#f00
6dd74de1933 classDef bar stroke:#0f0
6dd74de1934 classDef foobar stroke:#00f
6dd74de1935```
6dd74de1936
6dd74de1937### CSS classes
6dd74de1938
6dd74de1939It is also possible to predefine classes in CSS styles that can be applied from the graph definition as in the example
6dd74de1940below:
6dd74de1941
6dd74de1942**Example style**
6dd74de1943
6dd74de1944```html
6dd74de1945<style>
6dd74de1946 .cssClass > rect {
6dd74de1947 fill: #ff0000;
6dd74de1948 stroke: #ffff00;
6dd74de1949 stroke-width: 4px;
6dd74de1950 }
6dd74de1951</style>
6dd74de1952```
6dd74de1953
6dd74de1954**Example definition**
6dd74de1955
6dd74de1956```mermaid-example
6dd74de1957flowchart LR
6dd74de1958 A-->B[AAA<span>BBB</span>]
6dd74de1959 B-->D
6dd74de1960 class A cssClass
6dd74de1961```
6dd74de1962
6dd74de1963```mermaid
6dd74de1964flowchart LR
6dd74de1965 A-->B[AAA<span>BBB</span>]
6dd74de1966 B-->D
6dd74de1967 class A cssClass
6dd74de1968```
6dd74de1969
6dd74de1970### Default class
6dd74de1971
6dd74de1972If a class is named default it will be assigned to all classes without specific class definitions.
6dd74de1973
6dd74de1974```
6dd74de1975 classDef default fill:#f9f,stroke:#333,stroke-width:4px;
6dd74de1976```
6dd74de1977
6dd74de1978## Basic support for fontawesome
6dd74de1979
6dd74de1980It is possible to add icons from fontawesome.
6dd74de1981
6dd74de1982The icons are accessed via the syntax fa:#icon class name#.
6dd74de1983
6dd74de1984```mermaid-example
6dd74de1985flowchart TD
6dd74de1986 B["fa:fa-twitter for peace"]
6dd74de1987 B-->C[fa:fa-ban forbidden]
6dd74de1988 B-->D(fa:fa-spinner)
6dd74de1989 B-->E(A fa:fa-camera-retro perhaps?)
6dd74de1990```
6dd74de1991
6dd74de1992```mermaid
6dd74de1993flowchart TD
6dd74de1994 B["fa:fa-twitter for peace"]
6dd74de1995 B-->C[fa:fa-ban forbidden]
6dd74de1996 B-->D(fa:fa-spinner)
6dd74de1997 B-->E(A fa:fa-camera-retro perhaps?)
6dd74de1998```
6dd74de1999
6dd74de2000There are two ways to display these FontAwesome icons:
6dd74de2001
6dd74de2002### Register FontAwesome icon packs (v11.7.0+)
6dd74de2003
6dd74de2004You can register your own FontAwesome icon pack following the ["Registering icon packs" instructions](../config/icons.md).
6dd74de2005
6dd74de2006Supported prefixes: `fa`, `fab`, `fas`, `far`, `fal`, `fad`.
6dd74de2007
6dd74de2008> **Note**
6dd74de2009> Note that it will fall back to FontAwesome CSS if FontAwesome packs are not registered.
6dd74de2010
6dd74de2011### Register FontAwesome CSS
6dd74de2012
6dd74de2013Mermaid supports Font Awesome if the CSS is included on the website.
6dd74de2014Mermaid does not have any restriction on the version of Font Awesome that can be used.
6dd74de2015
6dd74de2016Please refer the [Official Font Awesome Documentation](https://fontawesome.com/start) on how to include it in your website.
6dd74de2017
6dd74de2018Adding this snippet in the `<head>` would add support for Font Awesome v6.5.1
6dd74de2019
6dd74de2020```html
6dd74de2021<link
6dd74de2022 href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"
6dd74de2023 rel="stylesheet"
6dd74de2024/>
6dd74de2025```
6dd74de2026
6dd74de2027### Custom icons
6dd74de2028
6dd74de2029It is possible to use custom icons served from Font Awesome as long as the website imports the corresponding kit.
6dd74de2030
6dd74de2031Note that this is currently a paid feature from Font Awesome.
6dd74de2032
6dd74de2033For custom icons, you need to use the `fak` prefix.
6dd74de2034
6dd74de2035**Example**
6dd74de2036
6dd74de2037```
6dd74de2038flowchart TD
6dd74de2039 B[fa:fa-twitter] %% standard icon
6dd74de2040 B-->E(fak:fa-custom-icon-name) %% custom icon
6dd74de2041```
6dd74de2042
6dd74de2043And trying to render it
6dd74de2044
6dd74de2045```mermaid-example
6dd74de2046flowchart TD
6dd74de2047 B["fa:fa-twitter for peace"]
6dd74de2048 B-->C["fab:fa-truck-bold a custom icon"]
6dd74de2049```
6dd74de2050
6dd74de2051```mermaid
6dd74de2052flowchart TD
6dd74de2053 B["fa:fa-twitter for peace"]
6dd74de2054 B-->C["fab:fa-truck-bold a custom icon"]
6dd74de2055```
6dd74de2056
6dd74de2057## Graph declarations with spaces between vertices and link and without semicolon
6dd74de2058
6dd74de2059- In graph declarations, the statements also can now end without a semicolon. After release 0.2.16, ending a graph statement with semicolon is just optional. So the below graph declaration is also valid along with the old declarations of the graph.
6dd74de2060
6dd74de2061- A single space is allowed between vertices and the link. However there should not be any space between a vertex and its text and a link and its text. The old syntax of graph declaration will also work and hence this new feature is optional and is introduced to improve readability.
6dd74de2062
6dd74de2063Below is the new declaration of the graph edges which is also valid along with the old declaration of the graph edges.
6dd74de2064
6dd74de2065```mermaid-example
6dd74de2066flowchart LR
6dd74de2067 A[Hard edge] -->|Link text| B(Round edge)
6dd74de2068 B --> C{Decision}
6dd74de2069 C -->|One| D[Result one]
6dd74de2070 C -->|Two| E[Result two]
6dd74de2071```
6dd74de2072
6dd74de2073```mermaid
6dd74de2074flowchart LR
6dd74de2075 A[Hard edge] -->|Link text| B(Round edge)
6dd74de2076 B --> C{Decision}
6dd74de2077 C -->|One| D[Result one]
6dd74de2078 C -->|Two| E[Result two]
6dd74de2079```
6dd74de2080
6dd74de2081## Configuration
6dd74de2082
6dd74de2083### Renderer
6dd74de2084
6dd74de2085The layout of the diagram is done with the renderer. The default renderer is dagre.
6dd74de2086
6dd74de2087Starting with Mermaid version 9.4, you can use an alternate renderer named elk. The elk renderer is better for larger and/or more complex diagrams.
6dd74de2088
6dd74de2089The _elk_ renderer is an experimental feature.
6dd74de2090You can change the renderer to elk by adding this directive:
6dd74de2091
6dd74de2092```
6dd74de2093config:
6dd74de2094 flowchart:
6dd74de2095 defaultRenderer: "elk"
6dd74de2096```
6dd74de2097
6dd74de2098> **Note**
6dd74de2099> Note that the site needs to use mermaid version 9.4+ for this to work and have this featured enabled in the lazy-loading configuration.
6dd74de2100
6dd74de2101### Width
6dd74de2102
6dd74de2103It is possible to adjust the width of the rendered flowchart.
6dd74de2104
6dd74de2105This is done by defining **mermaid.flowchartConfig** or by the CLI to use a JSON file with the configuration. How to use the CLI is described in the mermaidCLI page.
6dd74de2106mermaid.flowchartConfig can be set to a JSON string with config parameters or the corresponding object.
6dd74de2107
6dd74de2108```javascript
6dd74de2109mermaid.flowchartConfig = {
6dd74de2110 width: 100%
6dd74de2111}
6dd74de2112```
6dd74de2113
6dd74de2114<!--- cspell:ignore lagom --->