Top Related Projects
A JavaScript Typing Animation Library
A simple yet powerful native javascript plugin for a cool typewriter effect.
The most versatile JavaScript typewriter effect library on the planet.
Quick Overview
iTyped is a lightweight JavaScript library for creating typing animations. It allows developers to easily add dynamic, typewriter-style text effects to their web pages, enhancing user engagement and visual appeal.
Pros
- Simple and easy to use
- Lightweight with no dependencies
- Customizable with various options
- Supports multiple instances on a single page
Cons
- Limited animation styles compared to more comprehensive libraries
- Lacks advanced features like cursor customization
- No built-in support for complex text manipulations
- May require additional code for responsive designs
Code Examples
- Basic usage:
import { init } from 'ityped'
const element = document.querySelector('#element')
init(element, { showCursor: true, strings: ['Hello World!', 'iTyped is awesome!'] })
This code initializes iTyped on an element with the ID 'element', displaying two strings with a cursor.
- Using custom options:
import { init } from 'ityped'
const element = document.querySelector('#element')
init(element, {
showCursor: false,
typeSpeed: 100,
backSpeed: 50,
startDelay: 500,
backDelay: 1000,
loop: true,
strings: ['First string', 'Second string', 'Third string']
})
This example demonstrates using custom options to control the typing speed, delays, and looping behavior.
- Using callbacks:
import { init } from 'ityped'
const element = document.querySelector('#element')
init(element, {
strings: ['iTyped is great!'],
onInit: (instance) => console.log('iTyped initialized'),
onStart: (arrayPos, self) => console.log('Typing started'),
onFinished: (arrayPos, self) => console.log('Typing finished')
})
This code shows how to use callback functions to perform actions at different stages of the typing animation.
Getting Started
To use iTyped in your project, follow these steps:
-
Install iTyped via npm:
npm install ityped
-
Import and use iTyped in your JavaScript file:
import { init } from 'ityped' document.addEventListener('DOMContentLoaded', () => { const element = document.querySelector('#myElement') init(element, { showCursor: true, strings: ['Hello, World!', 'Welcome to iTyped!'] }) })
-
Make sure you have an element with the ID 'myElement' in your HTML:
<span id="myElement"></span>
That's it! You should now see the typing animation on your web page.
Competitor Comparisons
A JavaScript Typing Animation Library
Pros of typed.js
- More feature-rich with options like loop, smartBackspace, and cursor customization
- Better documentation and examples
- Larger community and more frequent updates
Cons of typed.js
- Larger file size (16.2 KB vs 1.1 KB for ityped)
- More complex setup and configuration
- Potentially slower performance due to additional features
Code Comparison
typed.js:
var typed = new Typed('#element', {
strings: ['First sentence.', 'Second sentence.'],
typeSpeed: 30
});
ityped:
ityped.init(document.querySelector("#element"), {
strings: ['First sentence.', 'Second sentence.'],
typeSpeed: 30
});
Both libraries offer similar basic functionality for creating typing animations. typed.js provides more options and customization, while ityped focuses on simplicity and small file size. The choice between the two depends on project requirements, with typed.js being better suited for complex animations and ityped for lightweight implementations.
A simple yet powerful native javascript plugin for a cool typewriter effect.
Pros of Typewriterjs
- More feature-rich, offering options like cursor customization and HTML support
- Better documentation and examples provided in the README
- Actively maintained with recent updates and bug fixes
Cons of Typewriterjs
- Larger file size, which may impact page load times
- More complex API, potentially requiring a steeper learning curve
- Requires more configuration for basic usage compared to iTyped
Code Comparison
iTyped:
ityped.init(document.querySelector("#element"), {
strings: ['String 1', 'String 2']
});
Typewriterjs:
const typewriter = new Typewriter('#element', {
loop: true,
delay: 75,
});
typewriter
.typeString('String 1')
.pauseFor(1000)
.deleteAll()
.typeString('String 2')
.start();
Both libraries offer typewriter-like functionality, but Typewriterjs provides more granular control over the typing process, allowing for pauses, deletions, and chaining of actions. iTyped, on the other hand, offers a simpler API for basic typewriter effects with less configuration required.
The most versatile JavaScript typewriter effect library on the planet.
Pros of TypeIt
- More feature-rich, offering advanced functionality like cursor customization and HTML parsing
- Better documentation and examples, making it easier for developers to implement
- Actively maintained with regular updates and bug fixes
Cons of TypeIt
- Larger file size, which may impact page load times for some applications
- Steeper learning curve due to more complex API and configuration options
- Requires more setup for basic typing animations compared to iTyped
Code Comparison
iTyped:
ityped.init(document.querySelector("#element"), {
strings: ['String 1', 'String 2'],
loop: true
});
TypeIt:
new TypeIt("#element", {
strings: ['String 1', 'String 2'],
loop: true,
cursor: true
}).go();
Summary
TypeIt offers more features and customization options, making it suitable for complex typing animations. However, this comes at the cost of a larger file size and potentially more complex implementation. iTyped, on the other hand, provides a simpler solution for basic typing animations with a smaller footprint, but lacks some advanced features and ongoing maintenance. The choice between the two depends on the specific requirements of your project and the level of customization needed.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
iTyped
Dead simple Animated typing, with no dependencies.
Enter in any string, and watch it type at the speed you've set, backspace what it's typed, and begin a new sentence for however many strings you've set.
Features
- iTyped has a tiny size: 2 kB.
- iTyped has no jQuery dependency.
- Just install and enjoy!
- Placeholder input support.
At now, if you just need to render Strings, iTyped is the best solution for you.
Installation
NPM
npm install ityped
Yarn
yarn add ityped
Browser
https://unpkg.com/ityped@1.0.3
CSS
CSS animations are build upon initialzation in JavaScript. But, you can customize them at your will! These classes are:
/* Cursor */
.ityped-cursor {}
Want the animated blinking cursor?
.ityped-cursor {
font-size: 2.2rem;
opacity: 1;
-webkit-animation: blink 0.3s infinite;
-moz-animation: blink 0.3s infinite;
animation: blink 0.3s infinite;
animation-direction: alternate;
}
@keyframes blink {
100% {
opacity: 0;
}
}
@-webkit-keyframes blink {
100% {
opacity: 0;
}
}
@-moz-keyframes blink {
100% {
opacity: 0;
}
}
Use with multiples instances at the same time
<span id="one"></span>
<span id="other"></span>
import { init } from 'ityped'
const oneElement = document.querySelector('#one')
const otherElement = document.querySelector('#other')
init(oneElement, { showCursor: false, strings: ['Nice', 'One' ] });
init(otherElement, { disableBackTyping: true, strings: ['iTyped is', 'Awesome'] });
Use with React.js
import React, { Component } from 'react'
import { init } from 'ityped'
export default class Hello extends Component {
componentDidMount(){
const myElement = document.querySelector('#myElement')
init(myElement, { showCursor: false, strings: ['Use with React.js!', 'Yeah!' ] })
}
render(){
return <div id="myElement"></div>
}
}
Customization
init("#element", {
/**
* @param {Array} strings An array with the strings that will be animated
*/
strings: ['Put your strings here...', 'and Enjoy!']
/**
* @param {Number} typeSpeed Type speed in milliseconds
*/
typeSpeed: 100,
/**
* @param {Number} backSpeed Type back speed in milliseconds
*/
backSpeed: 50,
/**
* @param {Number} startDelay Time before typing starts
*/
startDelay: 500,
/**
* @param {Number} backDelay Time before backspacing
*/
backDelay: 500,
/**
* @param {Boolean} loop The animation loop
*/
loop: false,
/**
* @param {Boolean} showCursor Show the cursor element
*/
showCursor: true,
/**
* @param {Boolean} placeholder Write the string in the placeholder content
*/
placeholder: false,
/**
* @param {Boolean} disableBackTyping Disable back typing for the last string sentence
*/
disableBackTyping: false,
/**
* @property {String} cursorChar character for cursor
*/
cursorChar: "|",
// optional: The callback called (if `loop` is false)
// once the last string was typed
/**
* @property {Function} onFinished The callback called , if `loop` is false,
* once the last string was typed
*/
onFinished: function(){},
}
Thanks for checking this out.
If you're using this, let me know! I'd love to see it.
Top Related Projects
A JavaScript Typing Animation Library
A simple yet powerful native javascript plugin for a cool typewriter effect.
The most versatile JavaScript typewriter effect library on the planet.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot