A JavaScript Typing Animation Library

samuel Ajax 194


Choose One

npm install typed.js
yarn add typed.js
bower install typed.js


<script src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11"></script>


This is really all you need to get going.

// Can also be included with a regular script tagimport Typed from 'typed.js';var options = {
  strings: ['<i>First</i> sentence.', '&amp; a second sentence.'],
  typeSpeed: 40};var typed = new Typed('.element', options);

Wonderful sites that have used (or are using) Typed.js














Strings from static HTML (SEO Friendly)

Rather than using the strings array to insert strings, you can place an HTML div on the page and read from it. This allows bots and search engines, as well as users with JavaScript disabled, to see your text on the page.

  var typed = new Typed('#typed', {
    stringsElement: '#typed-strings'
<div id="typed-strings">
  <p>Typed.js is a <strong>JavaScript</strong> library.</p>
  <p>It <em>types</em> out sentences.</p>
<span id="typed"></span>

Type Pausing

You can pause in the middle of a string for a given amount of time by including an escape character.

var typed = new Typed('.element', {  // Waits 1000ms after typing "First"
  strings: ['First ^1000 sentence.', 'Second sentence.']

Smart Backspacing

In the following example, this would only backspace the words after "This is a"

var typed = new Typed('.element', {
  strings: ['This is a JavaScript library', 'This is an ES6 module'],
  smartBackspace: true // Default value});

Bulk Typing

The following example would emulate how a terminal acts when typing a command and seeing its result.

var typed = new Typed('.element', {
  strings: ['git push --force ^1000\n `pushed to origin with option force`']


CSS animations are built upon initialzation in JavaScript. But, you can customize them at your will! These classes are:

/* Cursor */.typed-cursor {
}/* If fade out option is set */.typed-fade-out {

Use with ReactJS

Check out this example React app using Typed.js in a component: https://jsfiddle.net/mattboldt/ovat9jmp/

Use with Vue.js

Check out the Vue.js component: https://github.com/Orlandster/vue-typed-js

Use it as WebComponent

Check out the WebComponent: https://github.com/Orlandster/wc-typed-js


var typed = new Typed('.element', {  /**   * @property {array} strings strings to be typed   * @property {string} stringsElement ID of element containing string children   */
  strings: [    'These are the default values...',    'You know what you should do?',    'Use your own!',    'Have a great day!'
  stringsElement: null,  /**   * @property {number} typeSpeed type speed in milliseconds   */
  typeSpeed: 0,  /**   * @property {number} startDelay time before typing starts in milliseconds   */
  startDelay: 0,  /**   * @property {number} backSpeed backspacing speed in milliseconds   */
  backSpeed: 0,  /**   * @property {boolean} smartBackspace only backspace what doesn't match the previous string   */
  smartBackspace: true,  /**   * @property {boolean} shuffle shuffle the strings   */
  shuffle: false,  /**   * @property {number} backDelay time before backspacing in milliseconds   */
  backDelay: 700,  /**   * @property {boolean} fadeOut Fade out instead of backspace   * @property {string} fadeOutClass css class for fade animation   * @property {boolean} fadeOutDelay Fade out delay in milliseconds   */
  fadeOut: false,
  fadeOutClass: 'typed-fade-out',
  fadeOutDelay: 500,  /**   * @property {boolean} loop loop strings   * @property {number} loopCount amount of loops   */
  loop: false,
  loopCount: Infinity,  /**   * @property {boolean} showCursor show cursor   * @property {string} cursorChar character for cursor   * @property {boolean} autoInsertCss insert CSS for cursor and fadeOut into HTML <head>   */
  showCursor: true,
  cursorChar: '|',
  autoInsertCss: true,  /**   * @property {string} attr attribute for typing   * Ex: input placeholder, value, or just HTML text   */
  attr: null,  /**   * @property {boolean} bindInputFocusEvents bind to focus and blur if el is text input   */
  bindInputFocusEvents: false,  /**   * @property {string} contentType 'html' or 'null' for plaintext   */
  contentType: 'html',  /**   * Before it begins typing   * @param {Typed} self   */
  onBegin: (self) => {},  /**   * All typing is complete   * @param {Typed} self   */
  onComplete: (self) => {},  /**   * Before each string is typed   * @param {number} arrayPos   * @param {Typed} self   */
  preStringTyped: (arrayPos, self) => {},  /**   * After each string is typed   * @param {number} arrayPos   * @param {Typed} self   */
  onStringTyped: (arrayPos, self) => {},  /**   * During looping, after last string is typed   * @param {Typed} self   */
  onLastStringBackspaced: (self) => {},  /**   * Typing has been stopped   * @param {number} arrayPos   * @param {Typed} self   */
  onTypingPaused: (arrayPos, self) => {},  /**   * Typing has been started after being stopped   * @param {number} arrayPos   * @param {Typed} self   */
  onTypingResumed: (arrayPos, self) => {},  /**   * After reset   * @param {Typed} self   */
  onReset: (self) => {},  /**   * After stop   * @param {number} arrayPos   * @param {Typed} self   */
  onStop: (arrayPos, self) => {},  /**   * After start   * @param {number} arrayPos   * @param {Typed} self   */
  onStart: (arrayPos, self) => {},  /**   * After destroy   * @param {Typed} self   */
  onDestroy: (self) => {}


View Contribution Guidelines


Thanks for checking this out. If you have any questions, I'll be on Twitter.

If you're using this, let me know! I'd love to see it.

It would also be great if you mentioned me or my website somewhere. www.mattboldt.com

Related Post

Ajax IM What is Ajax IM? Ajax IM ("Ajax Instant Messenger") is an instant messenger for the web. It is Read more

pjax = pushState + ajax pjax is a jQuery plugin that uses ajax and pushState to deliver a fast browsing Read more

Ace (Ajax.org Cloud9 Editor) Note: The new site at http://ace.c9.io contains all the info below along with an embedding guide and all Read more

three.js       JavaScript 3D library The aim of the project is to create an easy to use, lightweight, 3D library Read more

Overview The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, Read more

Installation Use npm to install the latest version. npm install handsontable You can use Yarn, NuGet or other methods as well. You Read more

by Kris_B Image gallery simplified. Touch enabled, responsive, justified/cascading/grid layout and it supports cloud storage. Featuring multi-level navigation in albums, Read more

by Halil ibrahim Kalkan jTable is a jQuery plugin used to create AJAX based CRUD tables without coding HTML or Read more