You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
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

React typing animation based on typical.

1.1.1
Source
npm
Version published
Weekly downloads
84K
4.31%
Maintainers
1
Weekly downloads
 
Created
Source

react-type-animation

React type animation based on typical.

Install

npm install react-type-animation

Live Demo

A live demo can be found at: https://react-type-animation.vercel.app/

Usage

import TypeAnimation from 'react-type-animation';

const ExampleComponent = () => {
  return (
    <TypeAnimation
      cursor={false}
      sequence={['React typing animation based on typical', 1000, '']}
      wrapper="h2"
    />
  );
};

Important Usage Notes ⚠

Hot-Reload Bug

When using hot-reload, the type animation will most likely be bugged until you hard-reload the page. Until this issue is resolved, you need to hot-reload the page after ever code change in order to see the animation in a non-bugged state.

Layout-shift

In order to prevent layout shift caused the type animation's text HTML-element expanding, you need to either wrap the TextAnimation component in a div that has a fixed width/height which is wider than the maximum expansion of the TypeAnimation element, or make that wrapper div's position absolute.

Props

PropRequiredTypeExampleDescription
sequenceyesarray[]['One', 1000, 'Two']Animation sequence: TEXT followed by DELAY-IN-MS
wrappernostringp,h2,divHTML elements that Animation is wrapped around
repeatnonumber3, InfinityAmount of animation repetitions
cursornobooleanfalse, trueDisplay blinking cursor css-animation
classNamenostringcustom-class-nameHTML class name applied to the wrapper to style the text

Custom Cursor Animation

If you want to apply a custom cursor animation, set the cursor prop to false (which prevents any default css-styles from being applied) and set a custom className prop to the TypeAnimation component with your own css styles.

These are the base styles for the cursor animation:

.type::after {
  content: '|';
  animation: cursor 1.1s infinite step-start;
}

@keyframes cursor {
  50% {
    opacity: 0;
  }
}

If you want to modify the styles, simply make a styles.css file, copy and modify the styles and pass the prop className="type" to apply the custom styles.

If you would like the cursor to stop after a specific time, consider using a JSX styling library which lets you define CSS dynamically within your JSX Component, or simply replace infnite with a static finite number (like 2s) inside your custom css file.

Keywords

react

FAQs

Package last updated on 02 Jul 2021

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