Skip to content

Styling

LikeC4 provides advanced customization capabilities. You can change colors, shapes, sizes, and icons of elements and relationships.

There are multiple ways to style elements:

  • Style all elements of a kind in specification
  • Specific for an element in model or deployment
  • Override styles in view (more on this in next section)

To style all elements of a kind, use the style block in specification:

specification {
element user {
style {
// every element of 'user' kind
shape person // has 'person' shape
color amber // and amber color
}
}
element frontend {
style {
// every 'frontend' displayed as browser
shape: browser // ':' is optional, but if you prefer
}
}
}

To style a specific element, use the nested style block.
Element styles override ones from the kind:

specification {
element actor {
style {
shape person
color red
}
}
}
model {
customer = actor 'Customer' {
style {
// inherits shape and overrides color
color green
}
}
}

Next section clarifies how to customize elements per view.

specification {
element actor {
style {
shape person
}
}
}

Available shapes: rectangle (default), storage, cylinder, browser, mobile, person, queue.

specification {
element actor {
style {
color red
}
}
}

Available colors: primary (default), secondary, muted, amber, gray, green, indigo, red.

Size of an element is controlled by following properties:

propertyexplanation
sizesize of the shape
paddingspace around element’s title
textSizefont size of element’s title

Every property accepts: xsmall, small, medium, large, xlarge
(or short xs, sm, md, lg, xl).
Default size is medium.

When shape size is xsmall, only element’s title is displayed.

specification {
element element {
style {
size large
textSize xl
}
}
}

If element displayed as a group (like a container), you can set opacity:

specification {
element element {
style {
opacity 10%
}
}
}

If element displayed as a group (like a container), you can change border style:

specification {
element element {
style {
opacity 10%
border dotted
}
}
}

Supported values: dashed (default), dotted, solid, none

To display element as multiple instances, set multiple to true:

specification {
element element {
style {
multiple true
}
}
}

Elements may have an icon - any browser-supported image (png, svg, webp, etc.):

model {
pg = service 'PostgreSQL' {
style {
// Publicly available with `https://`
icon https://icons.terrastruct.com/dev%2Fpostgresql.svg
// or local image, relative to current file
icon ../postgresql.svg
}
}
}

With @ prefix, you can use aliased folders (learn more in configuration):

model {
pg = service 'PostgreSQL' {
style {
// local images, based on aliased folders
icon @/postgresql.svg
}
}
}

LikeC4 includes a set of icons from these packs:

Example:

model {
fn = service 'Lambda Function' {
icon aws:lambda
}
k8s = service 'K8s Service' {
icon gcp:google-kubernetes-engine
}
pg = storage 'PostgreSQL' {
icon tech:postgresql
}
}


There are multiple ways to style relationships:

  • Style all relationships of a kind in specification
  • Specific relationship in model
  • Customize per view (explained here)

Relationships can be styled in specification:

specification {
relationship async {
color amber
line dotted
head diamond
tail vee
}
}
model {
customer -> ui 'opens in browser' {
style {
line solid
color amber
}
}
}

Next section clarifies how to customize relationships per view.

Besides the color, relationships may have the following properties:

lineexample
dashed..
solid..
dotted..

By default, the line is dashed.

The arrow type can be set for the head and the tail of the relationship:

typeexample
normal..
onormal..
diamond..
odiamond..
crow..
vee..
open..
none..

onormal means “outlined normal”, i.e. no fill
odiamond - “outlined diamond”

By default, the head is normal and the tail is none.

model {
customer -> ui 'opens in browser' {
style {
head diamond
tail crow
}
}
}

How to override default styles is explained in project configuration