State Diagrams
State diagrams visualize the states an entity can be in and the transitions between those states. They are invaluable for modeling workflows, user interfaces, protocol behavior, and any system with distinct operational modes.
Basic Example
Section titled “Basic Example”stateDiagram-v2 [*] --> Idle Idle --> Running : start Running --> Paused : pause Paused --> Running : resume Running --> Stopped : stop Stopped --> [*]What You Get
Section titled “What You Get”Mermaid Studio provides solid support for state diagrams:
- Syntax highlighting for states, transitions, and labels
- Rename refactoring to update state names across the diagram
- Code folding to collapse composite states
- Brace matching for nested state definitions
- Inspections for detecting unreachable states and invalid transitions
- Color provider for styling state colors
Quick Syntax Reference
Section titled “Quick Syntax Reference”stateDiagram-v2 [*] --> Active
state Active { [*] --> Working Working --> Waiting : pause Waiting --> Working : resume }
Active --> Inactive : disable Inactive --> Active : enable Inactive --> [*]
note right of Active : Main operational stateKey elements:
[*]- Initial and final statesstate1 --> state2- Transition between statesstate1 --> state2 : event- Transition with event labelstate Name { }- Composite (nested) statenote- Add notes to states
For complete syntax details, see the Mermaid State Diagram documentation.