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 →
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 →
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 →
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 →
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 →
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 →
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 →
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 →
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 →
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 →
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 →
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 →
TypeFlow.erase('#el', { eraseStyle: 'start', speed: 24 });
center
#
Shrinks inward symmetrically from both edges toward the center. Try in Playground →
TypeFlow.erase('#el', { eraseStyle: 'center', speed: 24 });
scramble
#
Scrambles characters into randomized glyphs before clearing them. Try in Playground →
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 →
TypeFlow.erase('#el', { eraseStyle: 'fade-trail', trailFade: 6, speed: 20 });
instant
#
Clears the content immediately, with no animation. Try in Playground →
TypeFlow.erase('#el', { eraseStyle: 'instant' });
fade
#
A CSS opacity cross-fade on the whole element, then it clears. Try in Playground →
TypeFlow.erase('#el', { eraseStyle: 'fade', duration: 350 });
word-fade
#
Fades words out in place, without shifting the words that remain. Try in Playground →
TypeFlow.erase('#el', { eraseStyle: 'word-fade', wordFadeDuration: 400, wordStagger: 200 });
float-in-top
#
Words fade out while sliding up and away. Try in Playground →
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 →
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 →
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 →
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 →
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.
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.
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.
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.
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().
const caret = Caret('#el', { text: 'git commit' });
caret.jump(4);
await caret.insert('push --force ').promise;
// "git push --force commit"