diff --git a/docs/syntax/classDiagram.md b/docs/syntax/classDiagram.md index 20fdef0ed..2067cc97c 100644 --- a/docs/syntax/classDiagram.md +++ b/docs/syntax/classDiagram.md @@ -545,6 +545,38 @@ It is possible to annotate classes with markers to provide additional metadata a Annotations are defined within the opening `<<` and closing `>>`. There are two ways to add an annotation to a class, and either way the output will be same: +> **Tip:**\ +> In Mermaid class diagrams, annotations like `<>` can be attached in two ways: +> +> - **Inline with the class definition** (Recommended for consistency): +> +> ```mermaid-example +> classDiagram +> class Shape <> +> ``` +> +> ```mermaid +> classDiagram +> class Shape <> +> ``` +> +> - **Separate line after the class definition**: +> +> ```mermaid-example +> classDiagram +> class Shape +> <> Shape +> ``` +> +> ```mermaid +> classDiagram +> class Shape +> <> Shape +> ``` +> +> Both methods are fully supported and produce identical diagrams.\ +> However, it is recommended to use the **inline style** for better readability and consistent formatting across diagrams. + - In a **_separate line_** after a class is defined: ```mermaid-example diff --git a/packages/mermaid/src/docs/syntax/classDiagram.md b/packages/mermaid/src/docs/syntax/classDiagram.md index 33a1f9f6d..7ef81b96f 100644 --- a/packages/mermaid/src/docs/syntax/classDiagram.md +++ b/packages/mermaid/src/docs/syntax/classDiagram.md @@ -360,6 +360,27 @@ It is possible to annotate classes with markers to provide additional metadata a Annotations are defined within the opening `<<` and closing `>>`. There are two ways to add an annotation to a class, and either way the output will be same: +> **Tip:** +> In Mermaid class diagrams, annotations like `<>` can be attached in two ways: +> +> - **Inline with the class definition** (Recommended for consistency): +> +> ```mermaid-example +> classDiagram +> class Shape <> +> ``` +> +> - **Separate line after the class definition**: +> +> ```mermaid-example +> classDiagram +> class Shape +> <> Shape +> ``` +> +> Both methods are fully supported and produce identical diagrams. +> However, it is recommended to use the **inline style** for better readability and consistent formatting across diagrams. + - In a **_separate line_** after a class is defined: ```mermaid-example