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.

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 →

Character by character.
TypeFlow.type('#el', 'Character by character.', { typeStyle: 'char', speed: 45 });

word #

Reveals one whitespace-delimited word at a time instead of one grapheme at a time. Try in Playground →

Streaming word by word.
TypeFlow.type('#el', 'Streaming word by word.', { typeStyle: 'word', speed: 90 });

scramble #

Jitters through randomized glyphs before settling on each real character, matrix-decrypt style. Try in Playground →

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

fade-trail #

Reveals normally but keeps a soft trailing opacity ramp just behind the leading edge. Try in Playground →

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

word-fade #

Lays out the finished text once, then fades each word from transparent to visible without shifting anything’s position. Try in Playground →

Stable-layout word fade reveal.
TypeFlow.type('#el', 'Stable-layout word fade reveal.', {
  typeStyle: 'word-fade',
  wordOrder: 'left-to-right',
  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 →

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

float-in-bottom #

Words slide up into place from below as they fade in. Try in Playground →

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

float-in-left #

Words slide in from the left as they fade in. Try in Playground →

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

float-in-right #

Words slide in from the right as they fade in. Try in Playground →

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

zoom-in-space #

Words scale up from depth using a CSS perspective transform as they fade in. Try in Playground →

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

Erase Styles (eraseStyle) #

end #

The default. Backspace-style: removes characters from the right. Try in Playground →

Right-to-left backspace erase.
TypeFlow.erase('#el', { eraseStyle: 'end', speed: 24 });

start #

Removes characters from the left; the tail stays in place until the very end. Try in Playground →

Left-to-right erosion erase.
TypeFlow.erase('#el', { eraseStyle: 'start', speed: 24 });

center #

Shrinks inward symmetrically from both edges toward the center. Try in Playground →

Center-inward shrink erase.
TypeFlow.erase('#el', { eraseStyle: 'center', speed: 24 });

scramble #

Scrambles characters into randomized glyphs before clearing them. Try in Playground →

Matrix decrypt erase.
TypeFlow.erase('#el', { eraseStyle: 'scramble', scrambleCharset: 'matrix', scrambleRounds: 1, speed: 25 });

fade-trail #

Dissolves the trailing characters with a soft opacity ramp as it erases. Try in Playground →

Trailing opacity erase.
TypeFlow.erase('#el', { eraseStyle: 'fade-trail', trailFade: 6, speed: 20 });

instant #

Clears the content immediately, with no animation. Try in Playground →

Immediate reset erase.
TypeFlow.erase('#el', { eraseStyle: 'instant' });

fade #

A CSS opacity cross-fade on the whole element, then it clears. Try in Playground →

Smooth opacity fade erase.
TypeFlow.erase('#el', { eraseStyle: 'fade', duration: 350 });

word-fade #

Fades words out in place, without shifting the words that remain. Try in Playground →

Stable-layout word fade erase.
TypeFlow.erase('#el', { eraseStyle: 'word-fade', wordFadeDuration: 400, wordStagger: 200 });

float-in-top #

Words fade out while sliding up and away. Try in Playground →

Words leave upward.
TypeFlow.erase('#el', { eraseStyle: 'float-in-top', wordFadeDuration: 400, wordStagger: 200 });

float-in-bottom #

Words fade out while sliding down and away. Try in Playground →

Words leave downward.
TypeFlow.erase('#el', { eraseStyle: 'float-in-bottom', wordFadeDuration: 400, wordStagger: 200 });

float-in-left #

Words fade out while sliding left and away. Try in Playground →

Words leave leftward.
TypeFlow.erase('#el', { eraseStyle: 'float-in-left', wordFadeDuration: 400, wordStagger: 200 });

float-in-right #

Words fade out while sliding right and away. Try in Playground →

Words leave rightward.
TypeFlow.erase('#el', { eraseStyle: 'float-in-right', wordFadeDuration: 400, wordStagger: 200 });

zoom-in-space #

Words fade out while shrinking back into depth. Try in Playground →

Words recede into depth.
TypeFlow.erase('#el', { eraseStyle: 'zoom-in-space', wordFadeDuration: 450, wordStagger: 225 });

Caret Operations #

Caret is a separate, opt-in, zero-dependency module (@staticcanvas/typeflow/caret) — see the companion extensions guide 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’s bounds.

git commit -m wip
import { Caret } from '@staticcanvas/typeflow/caret';

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

move(delta) #

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

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

deleteChar(direction) #

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

Hello world
const caret = Caret('#el', { text: 'Hello world' });
caret.jump(11).deleteChar('backward').deleteChar('backward');
// "Hello wor"

deleteWord(direction) #

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

git commit -m wip
const caret = Caret('#el', { text: 'git commit -m wip' });
caret.jump(17).deleteWord('backward');
// "git commit -m "

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().

git commit
const caret = Caret('#el', { text: 'git commit' });
caret.jump(4);
await caret.insert('push --force ').promise;
// "git push --force commit"