Merlive

State diagrams

Read into the same boxes and links as a flowchart, so it is placed by the same rules and steps through the same way.

Declared with stateDiagram-v2. Of 27 features Mermaid documents for a state diagram, 19 drawn as written, 8 drawn less something. See all 27 drawn both ways, or draw one yourself.

Mermaid
State diagram, as Mermaid draws it
Merlive
State diagram, as Merlive draws it

What is read

stateDiagram and stateDiagram-v2 are read into the same boxes and links as a flowchart, so everything else on this page holds for them: the rules, the design, Merlive's own lines.

WrittenRead as
Draft, state "Being written" as Draft, Draft : Being writtenA state: a box. Words given a line at a time are kept as lines
Draft --> Sent, Draft --> Sent : sendA transition: a link, with its words
[*] --> Draft, Sent --> [*]Where it starts and where it ends: one pill each, saying Start and End. In Merlive's own lines they are start and end (%% main: start>Draft>Sent>end)
state Review { … }A composite state: a group, with a start and an end of its own (Review_start, Review_end). A transition to it is drawn to where it starts inside, and one from it from where it ends
Review : In review, state "In review" as Review {What a composite state is called
state enough <<choice>>A decision, with its name or its words in it
state split <<fork>>, state together <<join>>A bar across the flow, as Mermaid draws it: flat top to bottom, upright left to right, of the kind Fork or Join. Its name or words are not written on it; a reader hears them, and the side panel shows them
note right of Draft : words, note left of Draft … end noteThe note on that box: what a reader sees on picking it
direction LR, direction BT, direction RLThe way the diagram runs. Inside a composite state (or a region of one), the way its own states run: across the flow, they are a row, as a flowchart's group is
classDef, class Held, Lost stopped, Held:::stoppedKinds, as in a flowchart
-- inside a composite stateRegions that run side by side: each is a frame with no name inside the composite state, with a start of its own. A link into the composite state goes into every region
%% words after a line, hide empty description, scale 350 widthRead past

A composite state inside another is a group inside a group.

Feature by feature

Every feature Mermaid’s own pages set out for a state diagram, each with a sample of it in the corpus. A sample is drawn when every box, link and word it has is read and every rule passes. Drawn, less something is the same with one thing known to be missing, named beside it.

FeatureResultWhat is missing
A state diagram, declared with "stateDiagram-v2"Drawn
A state diagram, declared with "stateDiagram"Drawn
States named by their id aloneDrawn
A state with words, written "state words as id"Drawn
A state with words, written "id : words"Drawn
Words given a line at a timeDrawn
A name with spaces, by way of an idDrawn
TransitionsDrawn
Transitions with wordsDrawn
A transition from a state to itselfDrawn
Where it starts and where it endsDrawn, less somethingWhere it starts and where it ends are pills that say so, not dots
A composite stateDrawn, less somethingA transition to a composite state is drawn to where it starts inside, and one from it from where it ends
A composite state named on a line of its ownDrawn, less somethingA transition to a composite state is drawn to where it starts inside, and one from it from where it ends
A composite state inside anotherDrawn
Transitions between composite statesDrawn, less somethingA transition to a composite state is drawn to where it starts inside, and one from it from where it ends
A choiceDrawn, less somethingA choice is a decision the size of every box, with its name in it; Mermaid draws a small diamond with none
A fork and a joinDrawn
A note on one line, on either sideDrawn, less somethingA note is what a reader sees on picking its box in the page, and is printed with the page; it is not drawn beside the box, and a still picture does not carry it
A note written over several linesDrawn, less somethingA note is what a reader sees on picking its box in the page, and is printed with the page; it is not drawn beside the box, and a still picture does not carry it
Concurrency: regions of a composite state parted by --Drawn
The direction of the diagramDrawn
A composite state with a direction of its ownDrawn
Comments, on a line of their own and at the end of oneDrawn
A class made with classDef and given with classDrawn
A class given with :::Drawn
A title and a description for readers who cannot see itDrawn
A title and settings in front matterDrawn, less somethingMermaid's own settings are read past: the look is the design's

Written from skills/merlive/reference.md in the repository, so the two cannot disagree.

Before: FlowchartsNext: Class diagrams