Skip to content

Latest commit

 

History

History
78 lines (52 loc) · 3.35 KB

styling-elements.md

File metadata and controls

78 lines (52 loc) · 3.35 KB

Styling elements

By default, all model elements are rendered as grey boxes, as illustrated by the example diagram below.

Default styling

However, the following characteristics of the elements can be customized:

  • Width (pixels)
  • Height (pixels)
  • Background colour (HTML hex value)
  • Text colour (HTML hex value)
  • Font size (pixels)
  • Shape (see the Shape enum)
  • Border (Solid or Dashed; see the Border enum)
  • Opacity (an integer between 0 and 100)

Tagging elements

All elements within a software architecture model can have one or more tags associated with them. A tag is simply a free-format string. By default, the Java client library adds the following tags to elements.

Element Tags
Software System "Element", "Software System"
Person "Element", "Person"
Container "Element", "Container"
Component "Element", "Component"

All of these tags are defined as constants in the Tags class. As we'll see shortly, you can also add your own custom tags to elements using the addTags() method on the element.

Colour

To style an element, simply create an ElementStyle for a particular tag and specify the characteristics that you would like to change. For example, you can change the colour of all elements as follows.

Styles styles = workspace.getViews().getConfiguration().getStyles();
styles.addElementStyle(Tags.ELEMENT).background("#438dd5").color("#ffffff");

Colouring all elements

You can also change the colour of specific elements, for example based upon their type, as follows.

styles.addElementStyle(Tags.ELEMENT).color("#ffffff");
styles.addElementStyle(Tags.PERSON).background("#08427b");
styles.addElementStyle(Tags.CONTAINER).background("#438dd5");

Colouring elements based upon type

If you're looking for a colour scheme for your diagrams, try the Adobe Color Wheel or Paletton.

Shapes

You can also style elements using different shapes as follows.

styles.addElementStyle(Tags.ELEMENT).color("#ffffff");
styles.addElementStyle(Tags.PERSON).background("#08427b").shape(Shape.Person);
styles.addElementStyle(Tags.CONTAINER).background("#438dd5");
database.addTags("Database");
styles.addElementStyle("Database").shape(Shape.Cylinder);

Adding some shapes

As with CSS, styles cascade according to the order in which they are added. In the example above, the database element is coloured using the "Container" style, the shape of which is overriden by the "Database" style.

The set of available shapes is as follows:

The shapes available in Structurizr

Diagram key

Structurizr will automatically add all element styles to a diagram key, showing you which styles are associated with which tags.

The diagram key