Skip to content

LikeC4 Specification

The vocabulary of a project. See the authoring guide.

c4.contrib.likec4.Specification

The vocabulary of a project: kinds, tags and custom colors.

Declarations keep their order and a name may be declared only once per category.

element

element(
    name: str,
    *,
    title: str | None = None,
    technology: str | None = None,
    description: str | None = None,
    notation: str | None = None,
    tags: list[str] | tuple[str, ...] | None = None,
    **style: Any,
) -> Self

Declare an element kind.

Parameters:

Name Type Description Default
name str

Kind identifier.

required
title str | None

Default title.

None
technology str | None

Default technology.

None
description str | None

Default description.

None
notation str | None

Legend title.

None
tags list[str] | tuple[str, ...] | None

Tags applied to every element of the kind.

None
**style Any

Default element style properties.

{}

deployment_node

deployment_node(
    name: str,
    *,
    title: str | None = None,
    technology: str | None = None,
    description: str | None = None,
    notation: str | None = None,
    tags: list[str] | tuple[str, ...] | None = None,
    **style: Any,
) -> Self

Declare a deployment node kind.

Parameters:

Name Type Description Default
name str

Kind identifier.

required
title str | None

Default title.

None
technology str | None

Default technology.

None
description str | None

Default description.

None
notation str | None

Legend title.

None
tags list[str] | tuple[str, ...] | None

Tags applied to every node of the kind.

None
**style Any

Default style properties.

{}

relationship

relationship(
    name: str,
    *,
    technology: str | None = None,
    description: str | None = None,
    **style: Any,
) -> Self

Declare a relationship kind.

Parameters:

Name Type Description Default
name str

Kind identifier.

required
technology str | None

Default technology.

None
description str | None

Default description.

None
**style Any

Default relationship style properties.

{}

tag

tag(name: str, color: str | None = None) -> Self

Declare a tag.

Parameters:

Name Type Description Default
name str

Tag identifier, written without #.

required
color str | None

Optional theme or custom color name.

None

color

color(name: str, value: str) -> Self

Declare a custom color.

Parameters:

Name Type Description Default
name str

Color identifier.

required
value str

Hex or rgb()/rgba() value.

required

use

use(preset: Preset) -> Self

Declare every kind and tag of a preset, in the preset's order.

Names go through the same duplicate check as manual declarations.

Parameters:

Name Type Description Default
preset Preset

Preset to apply, such as C4.

required

c4.contrib.likec4.ElementKind dataclass

A declared element or deployment node kind.

Attributes:

Name Type Description
name str

Kind identifier.

title str | None

Default title for elements of the kind.

technology str | None

Default technology.

description str | None

Default description.

notation str | None

Legend title for the kind.

tags tuple[str, ...]

Tags applied to every element of the kind.

style dict[str, StyleValue]

Default style properties.

c4.contrib.likec4.RelationshipKind dataclass

A declared relationship kind.

Attributes:

Name Type Description
name str

Kind identifier.

technology str | None

Default technology.

description str | None

Default description.

style dict[str, StyleValue]

Default style properties.

c4.contrib.likec4.Tag dataclass

A declared tag; the name is written without #.

Attributes:

Name Type Description
name str

Tag identifier.

color str | None

Optional theme or custom color name.

c4.contrib.likec4.CustomColor dataclass

A custom named color.

Attributes:

Name Type Description
name str

Color identifier.

value str

Hex or rgb()/rgba() value.

c4.contrib.likec4.Preset dataclass

A set of kinds and tags applied with Specification.use.

A preset is plain data: it changes nothing until it is applied.

Attributes:

Name Type Description
elements tuple[ElementKind, ...]

Element kinds to declare.

relationships tuple[RelationshipKind, ...]

Relationship kinds to declare.

tags tuple[Tag, ...]

Tags to declare.

with_

with_(
    *,
    elements: Iterable[ElementKind] = (),
    relationships: Iterable[RelationshipKind] = (),
    tags: Iterable[Tag] = (),
) -> Preset

Return a copy with kinds and tags added or overridden.

An entry replaces the entry of the same name and keeps its position; a new name is appended.

Parameters:

Name Type Description Default
elements Iterable[ElementKind]

Element kinds to add or override.

()
relationships Iterable[RelationshipKind]

Relationship kinds to add or override.

()
tags Iterable[Tag]

Tags to add or override.

()

c4.contrib.likec4.C4 module-attribute

C4 = Preset(
    elements=(
        ElementKind(
            "person",
            title="Person",
            style=parse_element_style(
                shape="person", color="blue"
            ),
        ),
        ElementKind(
            "system",
            title="Software System",
            style=parse_element_style(color="primary"),
        ),
        ElementKind(
            "container",
            title="Container",
            style=parse_element_style(color="secondary"),
        ),
        ElementKind(
            "component",
            title="Component",
            style=parse_element_style(
                shape="component", color="muted"
            ),
        ),
        ElementKind(
            "database",
            title="Database",
            style=parse_element_style(
                shape="storage", color="secondary"
            ),
        ),
        ElementKind(
            "external",
            title="External System",
            style=parse_element_style(
                color="gray", border="dashed"
            ),
        ),
    )
)

The C4 vocabulary: six element kinds from the LikeC4 cheat-sheet.