The statemachine header (aliases state, fsm) draws states as stadium pills
and transitions as labelled arrows between them. A node named start or
initial becomes a filled circle; end or final becomes the ringed bullseye UML
draws for a final state.
The pseudo-states are matched by name. start, begin, and initial all draw
the entry dot; end, final, stop, and done all draw the exit marker.
Everything else is a normal state.
A transition is an edge, and the text after : is its trigger or guard. Several
transitions can leave one state, one per line, each with its own label. A state
that transitions to itself (Polling -> Polling : not ready) draws as a small
loop on that state.
A group { … } block is a composite state: the states inside it are its substates,
and groups nest. Mermaid's state X { } imports straight onto it.
Mermaid also splits a composite with a -- divider, meaning the parts above and
below run concurrently. Each side becomes its own nested group inside the
composite, so "these run in parallel" survives the import rather than flattening
into "these are siblings".
statemachinetitle: Keyboard
start -> Active
group Active {
group Active 1 {
NumLockOff, NumLockOn
}
group Active 2 {
CapsLockOff, CapsLockOn
}
}
NumLockOff -> NumLockOn : num lock
CapsLockOff -> CapsLockOn : caps lock
A composite state with two regions running at the same time.