# Reveal, erase & caret index

> Every typeStyle, eraseStyle, and Caret operation with a runnable code sample, a live demo, and a one-click link to try it in the playground.

Canonical documentation: https://staticcanvas.github.io/typeflow/guides/reveal-erase-caret-index/


## About This Index

Every value `typeStyle` and `eraseStyle` accept, plus every `Caret` operation, with a runnable code sample, a live demo, and a **Try in Playground** link that opens the same configuration ready to run. Use the on-page table of contents to jump straight to an entry.

The live demos below respect `prefers-reduced-motion`; with it enabled they render the finished state instead of animating.

---

## Reveal Styles (`typeStyle`)

### `char`

The default. Reveals text one grapheme at a time, left to right. [Try in Playground →](/playground/?typeStyle=char&amp;text=Character&#43;by&#43;character.&amp;speed=45)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;typeStyle&#34;:&#34;char&#34;,&#34;text&#34;:&#34;Character by character.&#34;,&#34;speed&#34;:45}&#39;&gt;Character by character.&lt;/div&gt;

```javascript
TypeFlow.type(&#39;#el&#39;, &#39;Character by character.&#39;, { typeStyle: &#39;char&#39;, speed: 45 });
```

### `word`

Reveals one whitespace-delimited word at a time instead of one grapheme at a time. [Try in Playground →](/playground/?typeStyle=word&amp;text=Streaming&#43;word&#43;by&#43;word.&amp;speed=90)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;typeStyle&#34;:&#34;word&#34;,&#34;text&#34;:&#34;Streaming word by word.&#34;,&#34;speed&#34;:90}&#39;&gt;Streaming word by word.&lt;/div&gt;

```javascript
TypeFlow.type(&#39;#el&#39;, &#39;Streaming word by word.&#39;, { typeStyle: &#39;word&#39;, speed: 90 });
```

### `scramble`

Jitters through randomized glyphs before settling on each real character, matrix-decrypt style. [Try in Playground →](/playground/?typeStyle=scramble&amp;text=Cybernetic&#43;decrypt&#43;reveal.&amp;scrambleCharset=matrix&amp;speed=40)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;typeStyle&#34;:&#34;scramble&#34;,&#34;text&#34;:&#34;Cybernetic decrypt reveal.&#34;,&#34;scrambleCharset&#34;:&#34;matrix&#34;,&#34;speed&#34;:40}&#39;&gt;Cybernetic decrypt reveal.&lt;/div&gt;

```javascript
TypeFlow.type(&#39;#el&#39;, &#39;Cybernetic decrypt reveal.&#39;, {
  typeStyle: &#39;scramble&#39;,
  scrambleCharset: &#39;matrix&#39;,
  scrambleRounds: 2,
  speed: 40,
});
```

### `fade-trail`

Reveals normally but keeps a soft trailing opacity ramp just behind the leading edge. [Try in Playground →](/playground/?typeStyle=fade-trail&amp;text=Trailing&#43;fade&#43;dissolve&#43;motion.&amp;speed=42&amp;trailFadeLength=6)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;typeStyle&#34;:&#34;fade-trail&#34;,&#34;text&#34;:&#34;Trailing fade dissolve motion.&#34;,&#34;speed&#34;:42,&#34;trailFade&#34;:6}&#39;&gt;Trailing fade dissolve motion.&lt;/div&gt;

```javascript
TypeFlow.type(&#39;#el&#39;, &#39;Trailing fade dissolve motion.&#39;, {
  typeStyle: &#39;fade-trail&#39;,
  trailFade: 6,
  speed: 42,
});
```

### `word-fade`

Lays out the finished text once, then fades each word from transparent to visible without shifting anything&#39;s position. [Try in Playground →](/playground/?typeStyle=word-fade&amp;text=Stable-layout&#43;word&#43;fade&#43;reveal.&amp;wordFadeDuration=400&amp;wordStagger=200)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;typeStyle&#34;:&#34;word-fade&#34;,&#34;text&#34;:&#34;Stable-layout word fade reveal.&#34;,&#34;wordFadeDuration&#34;:400,&#34;wordStagger&#34;:200}&#39;&gt;Stable-layout word fade reveal.&lt;/div&gt;

```javascript
TypeFlow.type(&#39;#el&#39;, &#39;Stable-layout word fade reveal.&#39;, {
  typeStyle: &#39;word-fade&#39;,
  wordOrder: &#39;left-to-right&#39;,
  wordFadeDuration: 400,
  wordStagger: 200,
});
```

### `float-in-top`

Same stable-layout word engine as `word-fade`, but each word also slides down into place from above. [Try in Playground →](/playground/?typeStyle=float-in-top&amp;text=Words&#43;arrive&#43;from&#43;above.&amp;wordFadeDuration=400&amp;wordStagger=200)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;typeStyle&#34;:&#34;float-in-top&#34;,&#34;text&#34;:&#34;Words arrive from above.&#34;,&#34;wordFadeDuration&#34;:400,&#34;wordStagger&#34;:200}&#39;&gt;Words arrive from above.&lt;/div&gt;

```javascript
TypeFlow.type(&#39;#el&#39;, &#39;Words arrive from above.&#39;, {
  typeStyle: &#39;float-in-top&#39;,
  wordFadeDuration: 400,
  wordStagger: 200,
});
```

### `float-in-bottom`

Words slide up into place from below as they fade in. [Try in Playground →](/playground/?typeStyle=float-in-bottom&amp;text=Words&#43;arrive&#43;from&#43;below.&amp;wordFadeDuration=400&amp;wordStagger=200)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;typeStyle&#34;:&#34;float-in-bottom&#34;,&#34;text&#34;:&#34;Words arrive from below.&#34;,&#34;wordFadeDuration&#34;:400,&#34;wordStagger&#34;:200}&#39;&gt;Words arrive from below.&lt;/div&gt;

```javascript
TypeFlow.type(&#39;#el&#39;, &#39;Words arrive from below.&#39;, {
  typeStyle: &#39;float-in-bottom&#39;,
  wordFadeDuration: 400,
  wordStagger: 200,
});
```

### `float-in-left`

Words slide in from the left as they fade in. [Try in Playground →](/playground/?typeStyle=float-in-left&amp;text=Words&#43;slide&#43;in&#43;from&#43;the&#43;left.&amp;wordFadeDuration=400&amp;wordStagger=200)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;typeStyle&#34;:&#34;float-in-left&#34;,&#34;text&#34;:&#34;Words slide in from the left.&#34;,&#34;wordFadeDuration&#34;:400,&#34;wordStagger&#34;:200}&#39;&gt;Words slide in from the left.&lt;/div&gt;

```javascript
TypeFlow.type(&#39;#el&#39;, &#39;Words slide in from the left.&#39;, {
  typeStyle: &#39;float-in-left&#39;,
  wordFadeDuration: 400,
  wordStagger: 200,
});
```

### `float-in-right`

Words slide in from the right as they fade in. [Try in Playground →](/playground/?typeStyle=float-in-right&amp;text=Words&#43;slide&#43;in&#43;from&#43;the&#43;right.&amp;wordFadeDuration=400&amp;wordStagger=200)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;typeStyle&#34;:&#34;float-in-right&#34;,&#34;text&#34;:&#34;Words slide in from the right.&#34;,&#34;wordFadeDuration&#34;:400,&#34;wordStagger&#34;:200}&#39;&gt;Words slide in from the right.&lt;/div&gt;

```javascript
TypeFlow.type(&#39;#el&#39;, &#39;Words slide in from the right.&#39;, {
  typeStyle: &#39;float-in-right&#39;,
  wordFadeDuration: 400,
  wordStagger: 200,
});
```

### `zoom-in-space`

Words scale up from depth using a CSS `perspective` transform as they fade in. [Try in Playground →](/playground/?typeStyle=zoom-in-space&amp;text=Perspective&#43;zoom&#43;word&#43;motion.&amp;wordFadeDuration=450&amp;wordStagger=225)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;typeStyle&#34;:&#34;zoom-in-space&#34;,&#34;text&#34;:&#34;Perspective zoom word motion.&#34;,&#34;wordFadeDuration&#34;:450,&#34;wordStagger&#34;:225}&#39;&gt;Perspective zoom word motion.&lt;/div&gt;

```javascript
TypeFlow.type(&#39;#el&#39;, &#39;Perspective zoom word motion.&#39;, {
  typeStyle: &#39;zoom-in-space&#39;,
  wordFadeDuration: 450,
  wordStagger: 225,
});
```

---

## Erase Styles (`eraseStyle`)

### `end`

The default. Backspace-style: removes characters from the right. [Try in Playground →](/playground/?eraseStyle=end&amp;text=Right-to-left&#43;backspace&#43;erase.&amp;speed=45)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;end&#34;,&#34;text&#34;:&#34;Right-to-left backspace erase.&#34;,&#34;speed&#34;:45}&#39;&gt;Right-to-left backspace erase.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;end&#39;, speed: 24 });
```

### `start`

Removes characters from the left; the tail stays in place until the very end. [Try in Playground →](/playground/?eraseStyle=start&amp;text=Left-to-right&#43;erosion&#43;erase.&amp;speed=45)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;start&#34;,&#34;text&#34;:&#34;Left-to-right erosion erase.&#34;,&#34;speed&#34;:45}&#39;&gt;Left-to-right erosion erase.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;start&#39;, speed: 24 });
```

### `center`

Shrinks inward symmetrically from both edges toward the center. [Try in Playground →](/playground/?eraseStyle=center&amp;text=Center-inward&#43;shrink&#43;erase.&amp;speed=45)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;center&#34;,&#34;text&#34;:&#34;Center-inward shrink erase.&#34;,&#34;speed&#34;:45}&#39;&gt;Center-inward shrink erase.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;center&#39;, speed: 24 });
```

### `scramble`

Scrambles characters into randomized glyphs before clearing them. [Try in Playground →](/playground/?eraseStyle=scramble&amp;text=Matrix&#43;decrypt&#43;erase.&amp;scrambleCharset=matrix&amp;speed=45)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;scramble&#34;,&#34;text&#34;:&#34;Matrix decrypt erase.&#34;,&#34;scrambleCharset&#34;:&#34;matrix&#34;,&#34;speed&#34;:45}&#39;&gt;Matrix decrypt erase.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;scramble&#39;, scrambleCharset: &#39;matrix&#39;, scrambleRounds: 1, speed: 25 });
```

### `fade-trail`

Dissolves the trailing characters with a soft opacity ramp as it erases. [Try in Playground →](/playground/?eraseStyle=fade-trail&amp;text=Trailing&#43;opacity&#43;erase.&amp;speed=45&amp;trailFadeLength=6)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;fade-trail&#34;,&#34;text&#34;:&#34;Trailing opacity erase.&#34;,&#34;speed&#34;:45,&#34;trailFade&#34;:6}&#39;&gt;Trailing opacity erase.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;fade-trail&#39;, trailFade: 6, speed: 20 });
```

### `instant`

Clears the content immediately, with no animation. [Try in Playground →](/playground/?eraseStyle=instant&amp;text=Immediate&#43;reset&#43;erase.&amp;speed=45)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;instant&#34;,&#34;text&#34;:&#34;Immediate reset erase.&#34;}&#39;&gt;Immediate reset erase.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;instant&#39; });
```

### `fade`

A CSS opacity cross-fade on the whole element, then it clears. [Try in Playground →](/playground/?eraseStyle=fade&amp;text=Smooth&#43;opacity&#43;fade&#43;erase.&amp;speed=45)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;fade&#34;,&#34;text&#34;:&#34;Smooth opacity fade erase.&#34;}&#39;&gt;Smooth opacity fade erase.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;fade&#39;, duration: 350 });
```

### `word-fade`

Fades words out in place, without shifting the words that remain. [Try in Playground →](/playground/?eraseStyle=word-fade&amp;text=Stable-layout&#43;word&#43;fade&#43;erase.&amp;wordFadeDuration=400&amp;wordStagger=200)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;word-fade&#34;,&#34;text&#34;:&#34;Stable-layout word fade erase.&#34;,&#34;wordFadeDuration&#34;:400,&#34;wordStagger&#34;:200}&#39;&gt;Stable-layout word fade erase.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;word-fade&#39;, wordFadeDuration: 400, wordStagger: 200 });
```

### `float-in-top`

Words fade out while sliding up and away. [Try in Playground →](/playground/?eraseStyle=float-in-top&amp;text=Words&#43;leave&#43;upward.&amp;wordFadeDuration=400&amp;wordStagger=200)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;float-in-top&#34;,&#34;text&#34;:&#34;Words leave upward.&#34;,&#34;wordFadeDuration&#34;:400,&#34;wordStagger&#34;:200}&#39;&gt;Words leave upward.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;float-in-top&#39;, wordFadeDuration: 400, wordStagger: 200 });
```

### `float-in-bottom`

Words fade out while sliding down and away. [Try in Playground →](/playground/?eraseStyle=float-in-bottom&amp;text=Words&#43;leave&#43;downward.&amp;wordFadeDuration=400&amp;wordStagger=200)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;float-in-bottom&#34;,&#34;text&#34;:&#34;Words leave downward.&#34;,&#34;wordFadeDuration&#34;:400,&#34;wordStagger&#34;:200}&#39;&gt;Words leave downward.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;float-in-bottom&#39;, wordFadeDuration: 400, wordStagger: 200 });
```

### `float-in-left`

Words fade out while sliding left and away. [Try in Playground →](/playground/?eraseStyle=float-in-left&amp;text=Words&#43;leave&#43;leftward.&amp;wordFadeDuration=400&amp;wordStagger=200)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;float-in-left&#34;,&#34;text&#34;:&#34;Words leave leftward.&#34;,&#34;wordFadeDuration&#34;:400,&#34;wordStagger&#34;:200}&#39;&gt;Words leave leftward.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;float-in-left&#39;, wordFadeDuration: 400, wordStagger: 200 });
```

### `float-in-right`

Words fade out while sliding right and away. [Try in Playground →](/playground/?eraseStyle=float-in-right&amp;text=Words&#43;leave&#43;rightward.&amp;wordFadeDuration=400&amp;wordStagger=200)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;float-in-right&#34;,&#34;text&#34;:&#34;Words leave rightward.&#34;,&#34;wordFadeDuration&#34;:400,&#34;wordStagger&#34;:200}&#39;&gt;Words leave rightward.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;float-in-right&#39;, wordFadeDuration: 400, wordStagger: 200 });
```

### `zoom-in-space`

Words fade out while shrinking back into depth. [Try in Playground →](/playground/?eraseStyle=zoom-in-space&amp;text=Words&#43;recede&#43;into&#43;depth.&amp;wordFadeDuration=450&amp;wordStagger=225)

&lt;div class=&#34;index-demo&#34; data-tf-demo=&#39;{&#34;eraseStyle&#34;:&#34;zoom-in-space&#34;,&#34;text&#34;:&#34;Words recede into depth.&#34;,&#34;wordFadeDuration&#34;:450,&#34;wordStagger&#34;:225}&#39;&gt;Words recede into depth.&lt;/div&gt;

```javascript
TypeFlow.erase(&#39;#el&#39;, { eraseStyle: &#39;zoom-in-space&#39;, wordFadeDuration: 450, wordStagger: 225 });
```

---

## Caret Operations

`Caret` is a separate, opt-in, zero-dependency module (`@staticcanvas/typeflow/caret`) — see the [companion extensions guide](/guides/extensions/#6-interactive-caret-staticcanvastypeflowcaret) for the full API and how it relates to the core engine. It has no playground panel of its own yet, so there is no **Try in Playground** link for these entries; each demo below runs the exact code shown.

### `jump(position)`

Moves the caret to an absolute grapheme index, clamped to the text&#39;s bounds.

&lt;div class=&#34;index-demo&#34; data-tf-caret-demo=&#39;{&#34;text&#34;:&#34;git commit -m wip&#34;,&#34;steps&#34;:[{&#34;op&#34;:&#34;jump&#34;,&#34;args&#34;:[4]}]}&#39;&gt;git commit -m wip&lt;/div&gt;

```javascript
import { Caret } from &#39;@staticcanvas/typeflow/caret&#39;;

const caret = Caret(&#39;#el&#39;, { text: &#39;git commit -m wip&#39; });
caret.jump(4);
```

### `move(delta)`

Moves the caret by a relative number of graphemes: positive moves right, negative moves left.

&lt;div class=&#34;index-demo&#34; data-tf-caret-demo=&#39;{&#34;text&#34;:&#34;npm run build&#34;,&#34;steps&#34;:[{&#34;op&#34;:&#34;move&#34;,&#34;args&#34;:[-5]}]}&#39;&gt;npm run build&lt;/div&gt;

```javascript
const caret = Caret(&#39;#el&#39;, { text: &#39;npm run build&#39; });
caret.move(-5);
```

### `deleteChar(direction)`

Deletes one grapheme: `&#39;backward&#39;` (Backspace, default) removes the character before the caret; `&#39;forward&#39;` (Delete) removes the character at/after it.

&lt;div class=&#34;index-demo&#34; data-tf-caret-demo=&#39;{&#34;text&#34;:&#34;Hello world&#34;,&#34;steps&#34;:[{&#34;op&#34;:&#34;jump&#34;,&#34;args&#34;:[11]},{&#34;op&#34;:&#34;deleteChar&#34;,&#34;args&#34;:[&#34;backward&#34;]},{&#34;op&#34;:&#34;deleteChar&#34;,&#34;args&#34;:[&#34;backward&#34;]}]}&#39;&gt;Hello world&lt;/div&gt;

```javascript
const caret = Caret(&#39;#el&#39;, { text: &#39;Hello world&#39; });
caret.jump(11).deleteChar(&#39;backward&#39;).deleteChar(&#39;backward&#39;);
// &#34;Hello wor&#34;
```

### `deleteWord(direction)`

Deletes the whitespace-delimited word adjacent to the caret, consuming the adjoining whitespace with it.

&lt;div class=&#34;index-demo&#34; data-tf-caret-demo=&#39;{&#34;text&#34;:&#34;git commit -m wip&#34;,&#34;steps&#34;:[{&#34;op&#34;:&#34;jump&#34;,&#34;args&#34;:[17]},{&#34;op&#34;:&#34;deleteWord&#34;,&#34;args&#34;:[&#34;backward&#34;]}]}&#39;&gt;git commit -m wip&lt;/div&gt;

```javascript
const caret = Caret(&#39;#el&#39;, { text: &#39;git commit -m wip&#39; });
caret.jump(17).deleteWord(&#39;backward&#39;);
// &#34;git commit -m &#34;
```

### `insert(text, config)`

Types `text` in at the caret position, one grapheme at a time, shifting following content to the right. Returns `{ stop, promise }` like `TypeFlow.type()`.

&lt;div class=&#34;index-demo&#34; data-tf-caret-demo=&#39;{&#34;text&#34;:&#34;git commit&#34;,&#34;steps&#34;:[{&#34;op&#34;:&#34;jump&#34;,&#34;args&#34;:[4]},{&#34;op&#34;:&#34;insert&#34;,&#34;args&#34;:[&#34;push --force &#34;]}]}&#39;&gt;git commit&lt;/div&gt;

```javascript
const caret = Caret(&#39;#el&#39;, { text: &#39;git commit&#39; });
caret.jump(4);
await caret.insert(&#39;push --force &#39;).promise;
// &#34;git push --force commit&#34;
```

