Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@0kzh/react-text-loop-next

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0kzh/react-text-loop-next

Create an animated loop of a list of text for your headings

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

react-text-loop-next

text-loop2

An animated loop of text nodes for your headings. Uses react-motion for the transition so it handles super fast animations and spring params. It's 6x smaller, maintained, but uses the same API as the original react-text-loop. Used by ant-design! Thanks to [@braposo]((https://github.com/braposo) for creating the original!

npm version npm downloads MIT License PRs Welcome


Installation

npm install react-text-loop-next or yarn add react-text-loop-next

How to use

Edit react-text-loop-next

You can also run the examples by cloning the repo and running yarn start.

Usage

import { TextLoop } from "react-text-loop-next";

const App = () => {
  return (
    <h2>
      <TextLoop>
        <span>First item</span>
        <a href="/">Second item</a>
        <p style={{ color: "red" }}>Third item</p>
      </TextLoop>{" "}
      and something else.
    </h2>
  );
};

Props

PropTypeDefaultDefinition
intervalnumber | array3000The frequency (in ms) that the words change. Can also pass an array if you want a different interval per children
delaynumber0A delay (in ms) for the animation to start. This allows to use multiple instances to create a staggered animation effect for example.
adjustingSpeednumber150The speed that the container around each word adjusts to the next one (in ms). Usually you don't need to change this.
fadebooleantrueEnable or disable the fade animation on enter and leave
maskbooleanfalseMask the animation around the bounding box of the animated content
noWrapbooleantrueDisable whitepace: nowrap style for each element. This is used by default so we can always get the right width of the element but can have issues sometimes.
springConfigobject{ stiffness: 340, damping: 30 }Configuration for react-motion spring
classNamestringAny additional CSS classes you might want to use to style the image
childrennodeThe words you want to loop (required)

Caveats

Because <TextLoop> loops through its children nodes, only root-level nodes will be considered so doing something like:

<TextLoop>
  <div>
    <span>First item</span>
    <span>Second item</span>
  </div>
  <div>Third item</div>
</TextLoop>

will make first and second item to be treated as one and animate together.

You can also just send a normal array as children prop if you don't need any individual styling for each node.

<TextLoop
  children={[
    "Trade faster",
    "Increase sales",
    "Stock winners",
    "Price perfectly",
  ]}
/>

Examples

Fast transition

text-loop-fast-small

<TextLoop interval={100}>...</TextLoop>

Wobbly animation

text-loop-bouncy

<TextLoop springConfig={{ stiffness: 180, damping: 8 }}>...</TextLoop>

For many other examples, please have a look at the CodeSandbox playground.

Contributing

Please follow our contributing guidelines.

License

MIT

Keywords

FAQs

Package last updated on 31 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