How to Create Animated Typing Effect (JavaScript)

animated-typing-effect-feature-image

If you want creating a dynamic typing animation that looks like the text is being typed by a typewriter then typer.js is the right solution for you:

It is written in native JavaScript (ES6) and works with almost no 3rd-party dependencies.

Download typer.js GitHub Link

How to Use It

Follow the steps:

Step 1: Include Typer.js library file by placing at the bottom of your HTML file.

<script async src="https://unpkg.com/typer-dot-js@0.1.0/typer.js"></script>

Step 2: Create an empty span element with the CSS class of typer , an id of main-typer and define an array of words in the data-words attribute:

<span class="typer" id="main-typer" data-words="Software Engineer, Front-end Developer,Designer" data-delay="100"></span>

You can also customize the typing delay, default is 200.

Step 3: Add the following after your typer span to create a cursor. Make sure to add id="main-typer" to the typer as well, or else cursor won’t know who to listen to.

<span class="cursor" data-owner="main-typer"></span>

That’s it. Here’s an example typer.js to get you started:

Example – 1 (Typing Effect – Typer.js)

See the Pen Typing Effect – Typer.js Example -1 by Sunil Pradhan (@Sunil_Pradhan) on CodePen.

Example – 2 (Using data-loop to stop on last word)

See the Pen Typing Effect – Typer.js (Using data-loop to stop on last word) Example -2 by Sunil Pradhan (@Sunil_Pradhan) on CodePen.

Other Famous JavaScript Libraries For Animated Typing Effect

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Similar articles you may like

By Sunil Pradhan

Hi there 👋 I am a front-end developer passionate about cutting-edge, semantic, pixel-perfect design. Writing helps me to understand things better.

Leave a comment

Your email address will not be published. Required fields are marked *

Exit mobile version