Components
Components must be bracketed.
You can also use the component
keyword to define a component. In this case the brackets can be omitted, but only if the component name does not include white-space or special characters.
You can define an alias, using the as
keyword.
This alias will be used later, when defining relations.
@startuml
[First component]
[Another component] as Comp2
component Comp3
component [Last\ncomponent] as Comp4
@enduml
Interfaces
Interface can be defined using the ()
symbol (because this looks like a circle).
You can also use the interface
keyword to define an interface.
And you can define an alias, using the as
keyword.
This alias will be used latter, when defining relations.
We will see latter that interface definition is optional.
Using notes
You can use the
note left of
, note right of
,
note top of
, note bottom of
keywords to define notes related to a single object.
@startuml
[Component] as C
note top of C: A top note
note bottom of C
A bottom note can also
be on several lines
end note
note left of C
A left note can also
be on several lines
end note
note right of C: A right note
@enduml
A note can be also defined alone with the note
keywords, then linked to other objects using the ..
symbol or whatever arrow symbol (-
, --
, …).
@startuml
[Component] as C
note as N
A floating note can also
be on several lines
end note
C .. N
@enduml
Another note example:
Grouping Components
You can use several keywords to group components and interfaces together:
* package
* node
* folder
* frame
* cloud
* database
@startuml
package "Some Group" {
HTTP - [First Component]
[Another Component]
}
node "Other Groups" {
FTP - [Second Component]
[First Component] --> FTP
}
cloud {
[Example 1]
}
database "MySql" {
folder "This is my folder" {
[Folder 3]
}
frame "Foo" {
[Frame 4]
}
}
[Another Component] --> [Example 1]
[Example 1] --> [Folder 3]
[Folder 3] --> [Frame 4]
@enduml
Changing arrows direction
By default, links between classes have two dashes --
and are vertically oriented.
It is possible to use horizontal link by putting a single dash (or dot) like this:
You can also change directions by reversing the link:
It is also possible to change arrow direction by adding left
, right
, up
or down
keywords inside the arrow:
@startuml
[Component] -left-> left
[Component] -right-> right
[Component] -up-> up
[Component] -down-> down
@enduml
You can shorten the arrow by using only the first character of the direction (for example, -d-
instead of
-down-
)
or the two first characters (-do-
).
Please note that you should not abuse this functionality : Graphviz gives usually good results without tweaking.
And with the link::use-case-diagram#d551e48d272b2b07[left to right direction
] parameter:
Using Sprite in Stereotype
You can use sprites within stereotype components.
@startuml
sprite $businessProcess [16x16/16] {
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFF0FFFFF
FFFFFFFFFF00FFFF
FF00000000000FFF
FF000000000000FF
FF00000000000FFF
FFFFFFFFFF00FFFF
FFFFFFFFFF0FFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
}
rectangle " End to End\nbusiness process" <<$businessProcess>> {
rectangle "inner process 1" <<$businessProcess>> as src
rectangle "inner process 2" <<$businessProcess>> as tgt
src -> tgt
}
@enduml
Skinparam
You can use the link::skinparam[skinparam] command to change colors and fonts for the drawing.
You can use this command : * In the diagram definition, like any other commands; * In an link::preprocessing[included file]; * In a configuration file, provided in the link::command-line[command line] or the link::ant-task[Ant task].
You can define specific color and fonts for stereotyped components and interfaces.
@startuml
skinparam interface {
backgroundColor RosyBrown
borderColor orange
}
skinparam component {
FontSize 13
BackgroundColor<> Pink
BorderColor<> #FF6655
FontName Courier
BorderColor black
BackgroundColor gold
ArrowFontName Impact
ArrowColor #FF6655
ArrowFontColor #777777
}
() "Data Access" as DA
Component "Web Server" as WS << Apache >>
DA - [First Component]
[First Component] ..> () HTTP : use
HTTP - WS
@enduml
Specific SkinParameter
componentStyle
-
By default (or with
skinparam componentStyle uml2
), you have an icon for component
@startuml skinparam BackgroundColor transparent skinparam componentStyle uml2 component A { component "A.1" { } component A.44 { [A4.1] } component "A.2" [A.3] component A.5 [ A.5] component A.6 [ ] } [a]->[b] @enduml
-
If you want to suppress it, and to have only the rectangle, you can use
skinparam componentStyle rectangle
@startuml skinparam BackgroundColor transparent skinparam componentStyle rectangle component A { component "A.1" { } component A.44 { [A4.1] } component "A.2" [A.3] component A.5 [ A.5] component A.6 [ ] } [a]->[b] @enduml
[Ref. 10798]
Hide or Remove unlinked component
By default, all components are displayed:
But you can:
* hide @unlinked
components:
-
or
remove @unlinked
components:
@startuml component C1 component C2 component C3 C1 -- C2 remove @unlinked @enduml
[Ref. QA-11052]
Hide, Remove or Restore tagged component or wildcard
You can put $tags
(using $
) on components, then remove, hide or restore components either individually or by tags.
By default, all components are displayed:
But you can:
* hide $tag13
components:
-
or
remove $tag13
components:
@startuml component C1 $tag13 component C2 component C3 $tag13 C1 -- C2 remove $tag13 @enduml
-
or
remove $tag13 and restore $tag1
components:
@startuml component C1 $tag13 $tag1 component C2 component C3 $tag13 C1 -- C2 remove $tag13 restore $tag1 @enduml
-
or
remove * and restore $tag1
components:
@startuml component C1 $tag13 $tag1 component C2 component C3 $tag13 C1 -- C2 remove * restore $tag1 @enduml
Display JSON Data on Component diagram
Simple example
@startuml
allowmixing
component Component
() Interface
json JSON {
"fruit":"Apple",
"size":"Large",
"color": ["Red", "Green"]
}
@enduml
[Ref. QA-15481]
For another example, see on link::json#2fyxla9p9ob6l3t3tjre[JSON page].