Get started

Install TypeFlow and create your first typewriter animation in vanilla JS or modern frameworks.

Installation #

Install @staticcanvas/typeflow version 0.35.0 from npm, jsr, or load it directly from modern CDNs.

npm install @staticcanvas/typeflow@0.35.0

Basic Usage #

Import the singleton TypeFlow instance and call type() on any DOM element or query selector string:

import { TypeFlow } from '@staticcanvas/typeflow';

// Animate a simple heading
const controller = TypeFlow.type('#headline', 'Building refined web experiences.', {
  speed: 45,
  cursor: '|',
  cursorBlink: true,
  onComplete: (text) => console.log('Animation completed:', text)
});

Erasing Content #

TypeFlow provides fine-grained erase control with multiple erase styles:

import { TypeFlow } from '@staticcanvas/typeflow';

// Erase from the right (backspace style)
TypeFlow.erase('#headline', {
  speed: 20,
  eraseStyle: 'end'
});

// Left-erosion erase style (start)
TypeFlow.erase('#headline', {
  speed: 15,
  eraseStyle: 'start'
});

Stopping Animations #

All type(), erase(), sequence(), and rotate() methods return a TypeFlowController object:

const controller = TypeFlow.type('#status', 'Fetching system metrics...');

// Abort typing at any time
button.addEventListener('click', () => {
  controller.stop();
});

// The controller promise always resolves safely without rejecting
controller.promise.then(({ completed, text }) => {
  if (!completed) {
    console.log('Interrupted early. Rendered text:', text);
  }
});

What’s Next? #

Edit on GitHub Last modified: