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.
A completely customizable framework for building rich text editors. (Currently in beta.)
Quick Overview
Typical is a small, fast, and fully-featured JavaScript animation library for animating text. It provides a simple API to create typewriter-like effects, with support for various options such as speed, delays, and custom functions for each character.
Pros
- Lightweight and fast, with no dependencies
- Flexible API with support for custom functions and options
- Easy to use and integrate into existing projects
- Supports both Node.js and browser environments
Cons
- Limited to text animations only
- May require additional setup for complex animations
- Documentation could be more comprehensive
Code Examples
Basic usage:
import { type } from 'typical';
type('Hello, world!').then(() => console.log('Done!'));
Using options:
type('Custom speed and delay', {
speed: 50,
delay: 1000
});
Custom function for each character:
type('Random delays', {
char: (char, { index }) => ({
delay: Math.random() * 100
})
});
Getting Started
- Install the package:
npm install typical
- Import and use in your project:
import { type } from 'typical';
type('Your text here').then(() => {
console.log('Animation complete!');
});
For more advanced usage and options, refer to the project's documentation on GitHub.
Competitor Comparisons
A JavaScript Typing Animation Library
Pros of Typed.js
- More feature-rich with options like backspacing, looping, and custom cursor
- Supports multiple strings and HTML tags within the typed text
- Larger community and more frequent updates
Cons of Typed.js
- Larger file size (17.4 KB vs 1.5 KB for Typical)
- More complex setup and configuration
- Potentially slower performance due to additional features
Code Comparison
Typical:
typical('#element', 'Hello, World!')
.then(() => console.log('Done typing'));
Typed.js:
new Typed('#element', {
strings: ['Hello, World!'],
typeSpeed: 50,
onComplete: (self) => console.log('Done typing')
});
Both libraries achieve similar basic functionality, but Typed.js offers more customization options at the cost of a slightly more complex setup. Typical provides a simpler, more lightweight solution for basic typing animations, while Typed.js is better suited for more advanced use cases requiring additional features and flexibility.
A simple yet powerful native javascript plugin for a cool typewriter effect.
Pros of Typewriterjs
- More feature-rich, offering options like cursor customization and loop functionality
- Provides better TypeScript support with type definitions
- Offers more control over typing speed and pauses between characters
Cons of Typewriterjs
- Larger file size, which may impact page load times
- More complex API, potentially requiring a steeper learning curve
- Less focused on performance optimization compared to Typical
Code Comparison
Typical:
typical('#element', 'Hello, World!')
.then(() => console.log('Done'));
Typewriterjs:
const typewriter = new Typewriter('#element', {
loop: true,
delay: 75,
});
typewriter
.typeString('Hello, World!')
.pauseFor(2500)
.deleteAll()
.start();
Summary
Typewriterjs 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. Typical, on the other hand, provides a simpler API and focuses on performance, making it ideal for straightforward typing effects with minimal overhead. The choice between the two depends on the specific requirements of your project and the level of control you need over the typing animation.
The most versatile JavaScript typewriter effect library on the planet.
Pros of TypeIt
- More feature-rich, offering advanced functionality like cursor simulation and HTML parsing
- Actively maintained with regular updates and improvements
- Extensive documentation and examples available
Cons of TypeIt
- Larger file size due to additional features
- Steeper learning curve for advanced usage
- Requires more configuration for simple typing animations
Code Comparison
TypeIt:
new TypeIt("#element", {
strings: "This is a typical string.",
speed: 50,
waitUntilVisible: true
}).go();
Typical:
typical("#element", {
text: "This is a typical string.",
delay: 50
});
Summary
TypeIt offers a more comprehensive solution for creating typing animations, with advanced features and regular updates. However, this comes at the cost of a larger file size and potentially more complex setup. Typical, on the other hand, provides a simpler, more lightweight option for basic typing animations, but with fewer customization options and less active maintenance.
Choose TypeIt for complex, feature-rich typing animations, especially in larger projects. Opt for Typical if you need a minimalistic, easy-to-implement solution for simple typing effects in smaller projects or where file size is a concern.
A completely customizable framework for building rich text editors. (Currently in beta.)
Pros of Slate
- More comprehensive and feature-rich, offering a complete rich text editing solution
- Highly customizable and extensible with plugins
- Better suited for complex document editing tasks
Cons of Slate
- Steeper learning curve due to its complexity
- Heavier in terms of bundle size and performance impact
- Requires more setup and configuration
Code Comparison
Typical (simple typing animation):
typical('#element', 'Hello, World!')
.then(() => console.log('Done!'));
Slate (basic editor setup):
const editor = withReact(createEditor());
const [value, setValue] = useState([
{ type: 'paragraph', children: [{ text: 'Hello, World!' }] },
]);
<Slate editor={editor} value={value} onChange={setValue}>
<Editable />
</Slate>
Summary
Typical is a lightweight library focused on creating typing animations, while Slate is a comprehensive rich text editing framework. Typical is easier to use for simple text animations, whereas Slate offers more power and flexibility for complex editing tasks but requires more setup and learning.
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
typical
Animated typing in ~400 bytes :blowfish: of JavaScript.
- Zero dependencies
- MIT licensed â
- Emoji support
- Smart delete: only delete what needs deleting
- Pausing: pause between steps
- Looping: easily loop from any point
- Waiting: wait on arbitrary Promises
- Humanity: slightly varied typing speed
Install
npm install @camwiegert/typical
More install options
Instead of using a package manager, you can download typical.js
from GitHub and import it locally or import it directly from a CDN like unpkg.
API
type(target: HTMLElement, ...steps: any[]) => Promise<void>;
The module exports a single function, type
, which takes a target element as its first argument, and any number of additional arguments as the steps to perform. Additional arguments perform actions based on their type:
Type | Action |
---|---|
string | Type text |
number | Pause (milliseconds) |
function | Call with target element |
Promise | Wait for resolution |
Usage
The most basic usage of type
is providing a target element and a string to type.
import { type } from '@camwiegert/typical';
type(element, 'text');
Pausing
In order to pause typing at any point, pass a number of milliseconds to pause.
type(element, 'Hello', 1000, 'Hello world!');
Looping
In order to loop, pass type
as a parameter to itself at the point at which you'd like to start looping. It can be helpful to alias type
as loop
to be explicit.
import {
type,
type as loop
};
const steps = [1000, 'Ready', 1000, 'Set', 1000, 'Go'];
type(element, ...steps, loop);
To loop a finite amount, pass your steps multiple times.
type(element, ...steps, ...steps, ...steps);
Waiting
When passed a Promise
, type
will wait for it to resolve before continuing. Because type
itself returns a Promise
, that means you can wait on a set of steps to complete before starting another.
const init = type(target, 'In a moment...', 500);
type(target, init, 'start', 500, 'looping', loop);
Functions
Function arguments are passed the target element, and can be useful for operating on the target element between steps. If you return a Promise
, type
will wait for it to resolve.
const toggle = (element) =>
element.classList.toggle('is-typing');
type(target, toggle, 'Type me', toggle);
Support
- Chrome
- Edge
- Firefox
- Safari
- Internet Explorer
Related
- react-typical - React component
- vue-typical - Vue component
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.
A completely customizable framework for building rich text editors. (Currently in beta.)
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