Class Diagrams
Class diagrams are the standard UML notation for documenting object-oriented designs. Use them to visualize classes, their attributes and methods, and the relationships between them.
Basic Example
Section titled “Basic Example”classDiagram class Animal { +String name +int age +makeSound() } class Dog { +bark() } class Cat { +meow() } Animal <|-- Dog Animal <|-- CatWhat You Get
Section titled “What You Get”Mermaid Studio provides good support for class diagrams:
- Syntax highlighting for classes, members, and relationships
- Code formatting to keep your diagrams tidy
- Inspections to catch common errors
- Color provider for customizing diagram colors
- Live preview to see your diagram as you type
Quick Syntax Reference
Section titled “Quick Syntax Reference”Defining Classes
Section titled “Defining Classes”classDiagram class ClassName { +publicMember -privateMember #protectedMember ~packageMember +publicMethod() -privateMethod() returnType }Relationships
Section titled “Relationships”| Syntax | Meaning |
|---|---|
<|-- | Inheritance |
*-- | Composition |
o-- | Aggregation |
--> | Association |
..> | Dependency |
..|> | Realization |
Cardinality
Section titled “Cardinality”classDiagram Customer "1" --> "*" Order : placesFor full syntax details, see the Mermaid class diagram documentation.