Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

State

A state is a rectangle with rounded corners. Internal behaviours go in a compartment under the name. A composite state holds other states.

diagram state "Simple and composite"
[*] --> Idle
Idle --> Running : start
state Running {
  entry / open()
  do / work()
  [*] --> Step
  Step --> [*]
}
Running --> [*]
Simple and composite Running entry / open() do / work() Step Idle start

Syntax

state <name> [as <alias>] [<<stereotype>>] [{ ... }]
entry|do|exit [/ expression]        inside a state, one per line
trigger {, trigger} [guard] / effect    internal transition, one per line

A name used in a transition declares a state. See State diagrams.

Specification

UML 2.5.1, 14.2.4.4 (p. 319). The final state is 14.2.4.5 (p. 327).

Used in

USB device, Process lifecycle.

See also

State diagrams (how to write the whole diagram), Elements of state diagrams, Grammar.