Skip to content

UML Component Diagram ​

To create a UML component diagram, use the componentDiagram function with component elements:

HyLiMo
componentDiagram {
    // define elements
}

All elements described below are also available in the general UML diagram.

Elements ​

component ​

Creates a new component element, supporting features similar to classes:

Class Features ​

For details, see UML Class Diagram

  • Properties and Methods: Define public, private, protected, package, or default sections for properties and methods, just like in class diagrams.
  • Abstract & Keywords: Use abstract = true to mark a component as abstract, and keywords = list("stereotype") to add stereotypes or keywords in guillemets (« »).
  • Replacing the keyword: Use keyword = "subsystem" to replace the «component» keyword, or keyword = false to hide it, see replacing the default keyword.

Nesting ​

Components can contain other components, classes, or interfaces, allowing for hierarchical organization:

Connections and interfaces between nested elements can be written where the elements are defined, also across components (see connections between nested elements):

Ports ​

Components can have ports, which are connection points for interfaces or other elements. Ports can be defined inside the component block or using dot notation outside:

Ports can also have interfaces (see below).

Required and Provided Interfaces ​

Components can declare required and provided interfaces using the provides and requires functions. These can be placed inside the component or attached to ports:

  • Syntax:
    • provides([name], pos, [target], dist = dist, namePos = [x, y])
    • requires([name], pos, [target], dist = dist, namePos = [x, y])
    • All arguments are optional.
    • name is the interface name (can be omitted).
    • pos is the relative position on the component outline (0 = right, 0.25 = bottom, 0.5 = left, 0.75 = top).
    • target can be used for directly connected notation.
    • dist controls the distance of the interface symbol from the component.
    • namePos can adjust the label position.

Example for directly connected notation:

Interfaces can also be attached to ports:

Connections / Associations ​

dependsOn ​

Instead of directly connecting a required to a provided interface, a dependsOn dashed arrow can be used:

WARNING

This connection operator is only supported for connecting required to provided interfaces, the layout will be incorrect for all other uses. Also, do not use the ..> operator for this use case.

Further Connections ​

For additional connection types (associations, aggregations, etc.), refer to the class diagram documentation.

Config properties ​

The following config properties are available for component diagrams:

VariableMeaningDefault value (in pixels)Comment
abstractAsPropertyWhether to show { abstract } after the name of abstract classesfalse-
providesDistanceDefault distance of provided interfaces to the classifier outline100-
requiresDistanceDefault distance of required interfaces to the classifier outline100-
showComponentKeywordWhether to show the component keywordtrue-
showComponentSymbolWhether to show the component symboltrue-

Styling ​

The following style variables are used by the component diagram elements:

VariableMeaningDefault value (in pixels)
componentIconSizeSize of the component symbol in the title25
providedInterfaceSizeDiameter of the circle of a provided interface30
requiredInterfaceSizeSize of the socket of a required interface45

Example ​

The following example shows the architecture of a small shop, using most of the elements described above: