Use Case Diagram Syntax
Use case diagrams (UML) show how actors interact with a system and its use cases. Available as usecase-beta (v11.17+).
Basic Structure
usecase-beta
direction LR
actor Customer("Customer")
systemBoundary "Order system"
Checkout("Place order")
end
Customer --> Checkoutusecase-beta— required first linedirection—TD,TB,BT,LR, orRL- Actors:
actor Name("Display label")— stick figure by default - Use cases:
Name("label")= ellipse,Name[label]= rectangle systemBoundary id["Title"] ... end— groups actors/use cases (defaultrect, or@{ type: package })
Actor Variants
usecase-beta
actor Normal("Normal actor")
actor Hollow("Hollow actor")@{ type: hollow }
actor Awesome("Awesome actor")@{ type: awesome }
actor Icon("Icon actor")@{ icon: "fa:user" }
actor B2B("Sales agent")@{ business: true } <<Employee>>
Normal --> Managetype:hollow|awesome(icon actors viaicon: "fa:name")business: trueadds the conventional business slash<<stereotype>>adds a visible stereotype above the label
Relationships
usecase-beta
actor Admin
actor Person
Checkout
Payment
ApplyCoupon
Admin --|> Person %% generalization
Checkout ..> : include Payment %% include
ApplyCoupon ..> : extend Checkout %% extend
User --> Start %% plain association
User --o Start %% circle (aggregation-like)
User --x Finish %% cross| Operator | Meaning |
|---|---|
-->, --, <-- |
Association |
--o, o-- |
Circle-end association |
--x, x-- |
Cross-end association |
..> : include X |
Include (source includes target) |
..> : extend X |
Extend (source extends target) |
--|> |
Generalization (specialized → general) |
Notes and JSON Tables
usecase-beta
note for Login "`Requires an **active session**`"
actor User
Login("Sign in")
User --> Login
json Payload@{
"status": "pending",
"items": [{ "name": "Book" }]
}:::data
Inspect --> Payloadnote for <target> "text"— attaches to an actor or use casejson <id>@{ ... }— renders a JSON object as a table node- Nested values use paths:
address.city,items[0].name
Styling
Classes and direct styles work like other Mermaid types: classDef, class, style, or ::: suffix on declarations. Use %% for comments; // and # are NOT comments in usecase diagrams.