New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-type-animation

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-type-animation

Customizable React typing animation component based on typical.

  • 3.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44K
decreased by-38.35%
Maintainers
1
Weekly downloads
 
Created
Source

react-type-animation

A customizable React typing animation component.

Installation

npm install react-type-animation

or

yarn add react-type-animation

Requires a react and react-dom version of at least 15.0.0.

Live Demo

A live demo and usage examples of the animation can be found at https://react-type-animation.netlify.app/examples.

Usage

A common typewriter animation for a landing page would look like this:

import { TypeAnimation } from 'react-type-animation';

const ExampleComponent = () => {
  return (
    <TypeAnimation
      sequence={[
        // Same substring at the start will only be typed out once, initially
        'We produce food for Mice',
        1000, // wait 1s before replacing "Mice" with "Hamsters"
        'We produce food for Hamsters',
        1000,
        'We produce food for Guinea Pigs',
        1000,
        'We produce food for Chinchillas',
        1000
      ]}
      wrapper="span"
      speed={50}
      style={{ fontSize: '2em', display: 'inline-block' }}
      repeat={Infinity}
    />
  );
};

Documentation

The docs with props, options and common problem solutions can be found at: https://react-type-animation.netlify.app/.

Migrating to v3

The default wrapper is now <span> instead of <div>: To migrate, add a display: inline-block/block or wrapper="div" to all <TypeAnimation/> occurances with unspecified wrapper.

Usage Notes

Immutability

Due to the nature of the animation, this component is permanently memoized, which means that the component never re-renders unless you hard-reload the page, and hence props changes will not be reflected.

Hot Reload NOT Supported

Because the TypeAnimation component is memoized and never re-rendered (see above), yet Hot Reload attempts to re-render the component, changes to the TypeAnimation component will not render until you hard-reload the page.

Hence, whenever you make changes to the TypeAnimation component, you unfortunately have to reload your page.

Props

See https://react-type-animation.netlify.app/options for more details.

PropRequiredTypeExampleDescriptionDefault
sequenceyesArray<number | string | (() => void | Promise)>['One', 1000, 'Two', () => console.log("done")]Animation sequence: [TEXT, DELAY-MS, CALLBACK]-
wrappernostringp,h2,div, strongHTML element tag that wraps the typing animationspan
speedno1,2,..,99 | {type: "keyStrokeDelayInMs", value: number}45, {type: "keyStrokeDelayInMs", value: 100}Speed for the writing of the animation40
deletionSpeedno1,2,..,99 | {type: "keyStrokeDelayInMs", value: number}45, {type: "keyStrokeDelayInMs", value: 100}Speed for deleting of the animationspeed
omitDeletionAnimationnobooleanfalse, trueIf true, deletions will be instant and without animationfalse
repeatnonumber0, 3, InfinityAmount of animation repetitions0
cursornobooleanfalse, trueDisplay default blinking cursor css-animationtrue
preRenderFirstStringnobooleanfalse, trueIf true, the first string of your sequence will not be animated and initially (pre-)renderedtrue
classNamenostringcustom-class-nameHTML class name applied to the wrapper to style the text-
stylenoobject{fontSize: '2em'}JSX inline style object-
refnoHTMLElement | null---
splitterno(text: string) => Array(str) => new GraphemeSplitter().splitGraphemes(str)Used for splitting complex characters, see grapheme-splitter for more detailsString.split('')




npm / github Credits: typical Shoutouts/Supporters: blockig

Keywords

FAQs

Package last updated on 10 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc