# Sequences

> Construct multi-step animations, dialogues, and coordinated DOM sequences with TypeFlow.

Canonical documentation: https://staticcanvas.github.io/typeflow/guides/sequences/


## Sequence Orchestration

`TypeFlow.sequence()` chains multiple animation steps cleanly without nested asynchronous promises or callbacks.

```javascript
import { TypeFlow, seq } from &#39;@staticcanvas/typeflow&#39;;

const sequenceController = TypeFlow.sequence([
  seq.type(&#39;#speaker&#39;, &#39;Agent: System scan initiated...&#39;),
  seq.pause(800),
  seq.call(() =&gt; console.log(&#39;Scan progress 50%&#39;)),
  seq.type(&#39;#speaker&#39;, &#39; Vulnerabilities detected: 0&#39;, { mode: &#39;append&#39; }),
  seq.pause(1200),
  seq.erase(&#39;#speaker&#39;, { eraseStyle: &#39;fade&#39;, duration: 400 }),
  seq.type(&#39;#speaker&#39;, &#39;Agent: Ready for mission.&#39;)
]);
```

## Step Helper Reference

TypeFlow exports the `seq` helper object to construct strongly-typed sequence steps:

| Helper | Arguments | Description |
| :--- | :--- | :--- |
| `seq.type()` | `target?, text, config?` | Types text into the specified element. |
| `seq.erase()` | `target?, config?` | Erases content from the specified element. |
| `seq.pause()` | `duration` | Pauses execution for `duration` milliseconds. |
| `seq.call()` | `fn: () =&gt; void \| Promise&lt;void&gt;` | Runs an arbitrary synchronous or asynchronous callback. |

## Sequence Configuration

Provide default options to the sequence runner:

```javascript
TypeFlow.sequence([
  seq.type(undefined, &#39;Step One&#39;),
  seq.pause(500),
  seq.erase(),
  seq.type(undefined, &#39;Step Two&#39;)
], {
  target: &#39;#default-container&#39;, // Default target for steps omitting a target
  repeat: 3                     // Loop 3 times (or Infinity for infinite loops)
});
```

