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.

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.
| Written | Read as |
|---|---|
Draft, state "Being written" as Draft, Draft : Being written | A state: a box. Words given a line at a time are kept as lines |
Draft --> Sent, Draft --> Sent : send | A 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 note | The note on that box: what a reader sees on picking it |
direction LR, direction BT, direction RL | The 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:::stopped | Kinds, as in a flowchart |
-- inside a composite state | Regions 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 width | Read 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.
| Feature | Result | What is missing |
|---|---|---|
| A state diagram, declared with "stateDiagram-v2" | Drawn | |
| A state diagram, declared with "stateDiagram" | Drawn | |
| States named by their id alone | Drawn | |
| A state with words, written "state words as id" | Drawn | |
| A state with words, written "id : words" | Drawn | |
| Words given a line at a time | Drawn | |
| A name with spaces, by way of an id | Drawn | |
| Transitions | Drawn | |
| Transitions with words | Drawn | |
| A transition from a state to itself | Drawn | |
| Where it starts and where it ends | Drawn, less something | Where it starts and where it ends are pills that say so, not dots |
| A composite state | Drawn, less something | A 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 own | Drawn, less something | A transition to a composite state is drawn to where it starts inside, and one from it from where it ends |
| A composite state inside another | Drawn | |
| Transitions between composite states | Drawn, less something | A transition to a composite state is drawn to where it starts inside, and one from it from where it ends |
| A choice | Drawn, less something | A 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 join | Drawn | |
| A note on one line, on either side | Drawn, less something | A 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 lines | Drawn, less something | A 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 diagram | Drawn | |
| A composite state with a direction of its own | Drawn | |
| Comments, on a line of their own and at the end of one | Drawn | |
| A class made with classDef and given with class | Drawn | |
| A class given with ::: | Drawn | |
| A title and a description for readers who cannot see it | Drawn | |
| A title and settings in front matter | Drawn, less something | Mermaid'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.