Skip to content

Roles

A role states what an element is. A design system sets how each role looks. The core gives every object and connection exactly one role, as the first entry of its D2 class list.

db: Orders {class: store}              # you pick the role
api: Orders API {class: [node; data]}  # role, then a design-system class

An element without a role gets its diagram’s default role (marked * below). D2 applies classes in order, and later classes take precedence. Classes you add after the role override the role’s styling.

Modifiers

Modifiers work in every diagram type. inkline does not treat them as roles.

ModifierMeaning
multipleseveral instances of the element
addednew in this change
changedmodified or passive
removedremoved or disabled

The carbon design system adds the architecture modifier prescribed and these domain colours: security, devops, application, data, network, observability, vpc, compute and backend.

Roles by diagram

architecture

KindRoles
nodecomponent*, actor, system, node, junction
containerlocation*, zone, subsystem
connectionconnection*, async

flowchart

KindRoles
nodeprocess*, start, end, decision, io, subprocess, store, note
containergroup*
connectionflow*, optional

sequence

KindRoles
participantparticipant*, actor
connectionmessage*, reply, async

A group, which is a top-level container that holds messages, takes no role.

state

KindRoles
nodestate*, start, end, choice, fork, join, note
containercomposite*
connectiontransition*

class

KindRoles
classclass*, interface, abstract, enum
connectionassociation*, inheritance, realization, composition, aggregation, dependency

Write connections from the child, implementer, whole or dependent end.

er

KindRoles
entityentity*
connectionrelation*, one-to-one, one-to-many, many-to-one, many-to-many

block

KindRoles
nodeblock*
containergroup*
connectionlink*

swimlanes

KindRoles
lanelane*
nodestep*, start, end, decision
connectionflow*, optional

quadrant

KindRoles
chartframe
quadrantquadrant
nodeitem*
axisaxis

treeview

KindRoles
noderoot, branch, leaf
connectionlink*

inkline assigns roles by depth. The top level is root, a node with children is a branch and every other node is a leaf.