npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-effect-typewriter

v1.0.2

Published

`react-effect-typewriter` is a lightweight and highly customizable React library that allows you to create captivating typewriter effects. The library's primary focus is on simplicity, customizability, SEO-friendliness and accessibility, ensuring that you

Downloads

57

Readme

React Effect Typewriter

react-effect-typewriter is a lightweight and highly customizable React library that allows you to create captivating typewriter effects. The library's primary focus is on simplicity, customizability, SEO-friendliness and accessibility, ensuring that you can deliver engaging text animations while maintaining best coding practices.

The package comprises two main components - Paragraph and Container. The Paragraph component animates your text to appear one character at a time, and the Container component, a wrapper component, can hold multiple Paragraph components or other nested Container components to create more complex animations.

Installation

npm install react-effect-typewriter

Usage

All you need to start using the library is importing it & using the Paragraph element & it'll immediately give you the effect, see the code below:

import * as Typewriter from "react-effect-typewriter";

const App = () => {
  return <Typewriter.Paragraph>Hello Typewriter!</Typewriter.Paragraph>;
};

Under the hood, the Typewriter.Paragraph is a normal <p> element, so you can pass to it any props you can normal pass to a <p> element like className, id, onClick, ...etc.

In addition to that, there are a couple of custom props that you can use to customize the effect. These options are: | Parameter | Description | Default Value | |-----------------|----------------------------------------------------------------------------------------------------------|---------------| | typingSpeed? | (Optional) The speed with which the characters are typed. Defined in milliseconds. | 50 | | startAnimation? | (Optional) If true, will start animation on mount, otherwise will wait for the prop value to become true. | true | | onStart? | (Optional) A callback that is triggered when the typing animation starts. | - | | onEnd? | (Optional) A callback that is triggered when the typing animation ends. | - | | onCancel? | (Optional) A callback that is triggered if the typing animation is cancelled. | - | | onCharacter? | (Optional) A callback that is triggered each time a character is typed. The typed character is passed as an argument to this function. | - |

Nesting Paragraphs

By default, the Paragraph element will start its animation as soon as it mounts on the DOM. However, you might have multiple paragraphs & you only want a paragraph to start appearing once the previous paragraphs have fully appeared, or you want them to only appear once a certain condition is met, for that, there is another element which is the Typewriter.Container element.

The Container element will make all its Paragraph children (doesn't have to be direct) only animate one after the other, based on the order of their appearance in the tree. It can also have another Container component as a children, so it will wait for the child Container to finish all its nested children before moving to other elements.

Example Usage:

import * as Typewriter from "react-effect-typewriter";

function App() {
  return (
    <Typewriter.Container>
      <Typewriter.Paragraph>This will appear #1</Typewriter.Paragraph>
      <Typewriter.Container>
        <Typewriter.Paragraph>This will appear #2</Typewriter.Paragraph>
        <Typewriter.Paragraph typingSpeed={20}>
          This will appear #3
        </Typewriter.Paragraph>
      </Typewriter.Container>
      <Typewriter.Paragraph typingSpeed={20}>
        This will appear #4
      </Typewriter.Paragraph>
    </Typewriter.Container>
  );
}

The Container component can take the following props:

| Parameter | Description | Default Value | | ----------------------- | --------------------------------------------------------------------------------------------------------- | ------------- | | typingSpeed? | (Optional) The speed with which the characters are typed. Defined in milliseconds. | - | | startAnimation? | (Optional) If true, will start animation on mount, otherwise will wait for the prop value to become true. | true | | delayBetweenElements? | (Optional) The delay between the start of the animation of each child element. Defined in milliseconds. | 0 |

How the effect is created

I've written a vanilla CSS/Javascript article a while ago explaining the core idea behind creating this effect in an accessible way, you can check this article here: How to create a typewriter effect that is accessible & SEO friendly

Feedback

If you have any feedback or suggestions for improvement, please feel free to open an issue or submit a pull request on GitHub. We appreciate your contributions!