Skip to content

Sequence, timeline, layers, cycle and tree

The structured diagram types and when to use each.

Not every diagram is a network of boxes. When the content is a conversation between parties, dates on a line, a stack, a loop or a hierarchy, the kit has a form for it that lays itself out. This page shows you when to use each of the five, which parts go inside it and how it builds by step. Each one goes in the diagram layout and needs a title prop, as a <Flow> does; for boxes and arrows, and for <Edge>, <Packet>, <State> and <Focus>, see Flow diagrams.

Sequence diagram

Use <SequenceDiagram> for who calls whom, in order: a protocol, an API handshake, a retry.

  • <Actor> goes inside <SequenceDiagram>: one per party, drawn as a node over its lifeline, with id, title, subtitle, kind, icon and card as on a node.
  • <Message> goes inside <SequenceDiagram>, after the actors, in order from top to bottom: from and to (the same actor for a call to itself), label, reply for a response (a dashed arrow) and async for fire-and-forget (a dashed arrow).

Each message takes at, the step that reveals it, and its arrow animates while that step is current. This one adds a message per step:

  1. An agent turn edits a working copy, and only content reaches the deck, step 0 (of steps 0 to 6).0start
  2. An agent turn edits a working copy, and only content reaches the deck, step 1 (of steps 0 to 6).1
  3. An agent turn edits a working copy, and only content reaches the deck, step 2 (of steps 0 to 6).2
  4. An agent turn edits a working copy, and only content reaches the deck, step 3 (of steps 0 to 6).3
  5. An agent turn edits a working copy, and only content reaches the deck, step 4 (of steps 0 to 6).4
  6. An agent turn edits a working copy, and only content reaches the deck, step 5 (of steps 0 to 6).5
  7. An agent turn edits a working copy, and only content reaches the deck, step 6 (of steps 0 to 6).6finished
showcase / agent-turn7 steps; select one to open the deck at that step in a new tab

The self-call on step 5 here is the point of the slide:

diagrams-demo / idempotent-chargeOpen full deck
decks/diagrams-demo/slides/idempotent-charge.mdxmdx
---
layout: diagram
title: An idempotency key makes a double click charge once
eyebrow: Sequence
budget: 1m30s
---

<SequenceDiagram title="A double-clicked payment, charged once thanks to its idempotency key">
  <Actor id="shopper" kind="user" title="Shopper" />
  <Actor id="web" kind="client" title="Web app" />
  <Actor id="payments" kind="service" title="Payments API" />
  <Actor id="ledger" kind="database" title="Ledger" />
  <Message from="shopper" to="web" label="Clicks Pay twice" at={1} />
  <Message from="web" to="payments" label="POST /charges, key k-71" at={2} />
  <Message from="payments" to="ledger" label="Insert k-71" at={3} />
  <Message from="web" to="payments" label="Same key again" at={4} />
  <Message from="payments" to="payments" label="k-71 seen: reuse result" at={5} />
  <Message from="payments" to="web" label="201, one charge" reply at={6} />
</SequenceDiagram>

<Notes>
The second POST carries the same key, so the API finds the first result and returns it instead of charging again. Pause on step five: that self-call is the whole trick.
</Notes>

Slide 7 of the diagrams-demo deckView on GitHub

Message labels sit above their arrows on one line, so keep them short.

Timeline

Use <Timeline> for milestones in time order with where you are now: a roadmap, a migration, a history.

  • <Milestone> goes inside <Timeline>, in time order: date as it should read (Q1 2026), title, a short line of detail as its children, and optionally state (success for done, as below) and icon.

Each milestone takes at. The line fills up to the latest milestone shown, or to the one marked current, which stays current once revealed while later milestones appear:

A timeline on a forest-green gradient with four quarters of 2026: Split checkout, Move payments, Region cells and Retire the monolith, each with a line of detail; the Q3 milestone, Region cells, has a filled ochre marker to show it is current.
diagrams-demo / migration-timelineOpen in the deck
<Milestone date="Q3 2026" title="Region cells" at={3} current>EU and US apart</Milestone>

The timeline layout draws the same <Timeline> from frontmatter: three to five milestones: with date, title, detail and state, a current: milestone number and reveal: true for one milestone per click. Use the layout when the timeline is the whole slide and fits its limits; use the component in the diagram layout when you want an <Aside> beside it or six milestones. The layout’s fields are on its page.

Layers

Use <Layers> for a stacked architecture or an ownership map: bands from top to bottom, each with its building blocks.

  • <Layer> goes inside <Layers>, top to bottom: title, subtitle (what it does or who owns it), at, state and card.
  • <Item> goes inside <Layer> only: a chip with title, kind (for its icon), icon, state and card.

Give each layer an at to build the stack band by band. While the stack builds, the band each step adds is picked out; once the last band is in, only bands with a state stand out, so mark the band the slide is about with state="highlighted".

A stack of five pale bands, Experience, Edge, Services, Data and Infrastructure, each with its owning team under the name and chips with icons such as Web, CDN, Orders, Postgres, Kafka and Kubernetes.
diagrams-demo / platform-layersOpen in the deck

Cycle

Use <Cycle> for a loop of stages that repeats: an incident loop, a feedback cycle, an agent loop.

  • <Node> goes inside <Cycle>: one per stage, in order from the top.
  • <Edge> between two consecutive stages labels or styles that arc; <State>, <Packet> and <Focus> work as in a <Flow>.

steps walks the loop one stage per step; spin keeps a packet circling while the slide is on screen.

A dark slide with four stages on an oval loop, Detect, Respond, Recover and Learn, joined by arrows; Detect has a highlighted outline and the arc from Learn back to Detect is lit, with a dot on it.
diagrams-demo / incident-loopOpen in the deck
<Cycle title="The incident loop: detect, respond, recover, learn" steps>
  <Node id="detect" kind="service" title="Detect" subtitle="Alerts and SLOs" />
  <Node id="respond" kind="user" title="Respond" subtitle="On-call engineer" />
  <Node id="recover" kind="function" title="Recover" subtitle="Roll back or fail over" />
  <Node id="learn" kind="document" title="Learn" subtitle="Blameless review" />
</Cycle>

Tree

Use <Tree> for a hierarchy: an org chart, a decision tree, a module tree.

  • One root <Node> goes inside <Tree>, and every child <Node> is nested inside its parent.

direction is down (the default) or right. at on a node reveals its branch:

A decision tree growing down from a diamond labelled Price? into Zone, Weight and Speed, each with an icon, and their leaves: Urban €3.90, Rural €5.40, Under 2 kg +€0, Over 2 kg +€1.50 and Same day ×1.8, which has a highlighted outline.
diagrams-demo / pricing-treeOpen in the deck
<Node id="weight" kind="node" icon="package" title="Weight" subtitle="Surcharge" at={2}>
  <Node id="light" title="Under 2 kg" subtitle="+€0" at={2} />
  <Node id="heavy" title="Over 2 kg" subtitle="+€1.50" at={2} />
</Node>

Cards

Four of the five forms take card, the node style a brand defines, as a <Flow> does: put it on one part, or on the diagram for all its parts, and a part’s own card wins. Choosing a card, the order a node follows and the standard names are on flow diagrams.

Form Takes card
<SequenceDiagram> On <Actor>, or on the diagram for every actor.
<Layers> On <Item>, on <Layer> for its band, and on <Layers> for every item.
<Cycle> On each stage’s <Node>, or on the cycle.
<Tree> On each <Node>, or on the tree.
<Timeline> No: milestones take no card.

On <Layers> the bands keep the stack’s own look, a tint with a bold left edge, unless a <Layer> names a card; the stack’s card styles only the item chips. Here the item chips are outlines, the services band is on tint and Payments is on solid:

<Layers title="The platform in three layers, with the services layer and the payments service marked" card="outline">
  <Layer title="Edge" subtitle="Platform team">
    <Item kind="cloud" title="CDN" />
    <Item kind="gateway" title="API gateway" />
  </Layer>
  <Layer title="Services" subtitle="Domain teams" card="tint">
    <Item kind="service" title="Orders" />
    <Item kind="service" title="Payments" card="solid" />
    <Item kind="service" title="Routing" />
  </Layer>
  <Layer title="Data" subtitle="Data team">
    <Item kind="database" title="Postgres" />
    <Item kind="queue" title="Kafka" />
  </Layer>
</Layers>

Limits

deck diagrams gives each form these limits. They are guidance for one slide: a sequence of seven actors and a tree of 13 nodes both lint without a finding. Past them, split the diagram over two slides.

Form Limits
<SequenceDiagram> 6 actors, 10 messages
<Timeline> 6 milestones
<Layers> 6 layers, 6 items per layer
<Cycle> 8 stages
<Tree> 12 nodes, 7 leaves, depth 4

Every prop of every part is on the diagram reference.

Type to search…

↑↓ navigate↵ selectEsc close