Skip to content

Commit 09ecf76

Browse files
Updated doc for image and icon shapes
1 parent 2b86750 commit 09ecf76

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

docs/syntax/flowchart.md

+60
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,66 @@ flowchart TD
926926
A@{ shape: tag-rect, label: "Tagged process" }
927927
```
928928

929+
## Special shapes in Mermaid Flowcharts (v11.3.0+)
930+
931+
Mermaid 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.
932+
933+
### Icon Shape
934+
935+
You 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 provided [here](https://mermaid.js.org/syntax/architecture.html#icons). The syntax for defining an icon shape is as follows:
936+
937+
```mermaid-example
938+
flowchart TD
939+
A@{ icon: "fa:user", form: "square", label: "User Icon", pos: "t", h: 60 }
940+
```
941+
942+
```mermaid
943+
flowchart TD
944+
A@{ icon: "fa:user", form: "square", label: "User Icon", pos: "t", h: 60 }
945+
```
946+
947+
### Parameters
948+
949+
- **icon**: The name of the icon from the registered icon pack.
950+
- **form**: Specifies the background shape of the icon. If not defined there will be no background to icon. Options include:
951+
- `square`
952+
- `circle`
953+
- `rounded`
954+
- **label**: The text label associated with the icon. This can be any string. If not defined, no label will be displayed.
955+
- **pos**: The position of the label. If not defined label will default to bottom of icon. Possible values are:
956+
- `t`
957+
- `b`
958+
- **h**: The height of the icon. If not defined this will default to 48 which is minimum.
959+
960+
### Image Shape
961+
962+
You can use the `image` shape to include an image in your flowchart. The syntax for defining an image shape is as follows:
963+
964+
```mermaid-example
965+
flowchart TD
966+
A@{ img: "https://example.com/image.png", label: "Image Label", pos: "t", w: 60, h: 60, constraint: "off" }
967+
```
968+
969+
```mermaid
970+
flowchart TD
971+
A@{ img: "https://example.com/image.png", label: "Image Label", pos: "t", w: 60, h: 60, constraint: "off" }
972+
```
973+
974+
### Parameters
975+
976+
- **img**: The URL of the image to be displayed.
977+
- **label**: The text label associated with the image. This can be any string. If not defined, no label will be displayed.
978+
- **pos**: The position of the label. If not defined, the label will default to the bottom of the image. Possible values are:
979+
- `t`
980+
- `b`
981+
- **w**: The width of the image. If not defined, this will default to the natural width of the image.
982+
- **h**: The height of the image. If not defined, this will default to the natural height of the image.
983+
- **constraint**: Determines if the image should constrain the node size. This setting also ensures the image maintains its original aspect ratio, adjusting the height (`h`) accordingly to the width (`w`). If not defined, this will default to `off` Possible values are:
984+
- `on`
985+
- `off`
986+
987+
These new shapes provide additional flexibility and visual appeal to your flowcharts, making them more informative and engaging.
988+
929989
## Links between nodes
930990

931991
Nodes can be connected with links/edges. It is possible to have different types of links or attach a text string to a link.

packages/mermaid/src/docs/syntax/flowchart.md

+50
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,56 @@ flowchart TD
542542
A@{ shape: tag-rect, label: "Tagged process" }
543543
```
544544

545+
## Special shapes in Mermaid Flowcharts (v11.3.0+)
546+
547+
Mermaid 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.
548+
549+
### Icon Shape
550+
551+
You 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 provided [here](https://mermaid.js.org/syntax/architecture.html#icons). The syntax for defining an icon shape is as follows:
552+
553+
```mermaid-example
554+
flowchart TD
555+
A@{ icon: "fa:user", form: "square", label: "User Icon", pos: "t", h: 60 }
556+
```
557+
558+
### Parameters
559+
560+
- **icon**: The name of the icon from the registered icon pack.
561+
- **form**: Specifies the background shape of the icon. If not defined there will be no background to icon. Options include:
562+
- `square`
563+
- `circle`
564+
- `rounded`
565+
- **label**: The text label associated with the icon. This can be any string. If not defined, no label will be displayed.
566+
- **pos**: The position of the label. If not defined label will default to bottom of icon. Possible values are:
567+
- `t`
568+
- `b`
569+
- **h**: The height of the icon. If not defined this will default to 48 which is minimum.
570+
571+
### Image Shape
572+
573+
You can use the `image` shape to include an image in your flowchart. The syntax for defining an image shape is as follows:
574+
575+
```mermaid-example
576+
flowchart TD
577+
A@{ img: "https://example.com/image.png", label: "Image Label", pos: "t", w: 60, h: 60, constraint: "off" }
578+
```
579+
580+
### Parameters
581+
582+
- **img**: The URL of the image to be displayed.
583+
- **label**: The text label associated with the image. This can be any string. If not defined, no label will be displayed.
584+
- **pos**: The position of the label. If not defined, the label will default to the bottom of the image. Possible values are:
585+
- `t`
586+
- `b`
587+
- **w**: The width of the image. If not defined, this will default to the natural width of the image.
588+
- **h**: The height of the image. If not defined, this will default to the natural height of the image.
589+
- **constraint**: Determines if the image should constrain the node size. This setting also ensures the image maintains its original aspect ratio, adjusting the height (`h`) accordingly to the width (`w`). If not defined, this will default to `off` Possible values are:
590+
- `on`
591+
- `off`
592+
593+
These new shapes provide additional flexibility and visual appeal to your flowcharts, making them more informative and engaging.
594+
545595
## Links between nodes
546596

547597
Nodes can be connected with links/edges. It is possible to have different types of links or attach a text string to a link.

0 commit comments

Comments
 (0)