# react-text-transition

> A React plugin that animates your text when it changes.

Latest version **3.1.0** (published 2023-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-text-transition
pnpm add react-text-transition
yarn add react-text-transition
bun add react-text-transition
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2023-04-09 |
| First published | 2018-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 23.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 635 |
| Author | WinterCore |
| Maintainers | wintercore |
| Keywords | react, text, transition, animation, motion, plugin |

## Links

- npm: https://www.npmjs.com/package/react-text-transition
- Repository: https://github.com/WinterCore/react-text-transition
- Homepage: https://github.com/WinterCore/react-text-transition#readme
- Issues: https://github.com/WinterCore/react-text-transition/issues
- npm.io page: https://npm.io/package/react-text-transition

## Dependencies (1)

- [@react-spring/web](https://npm.io/package/@react-spring/web.md) ^9.7.2

## Alternatives

- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [persona-harness](https://npm.io/package/persona-harness.md) — 4.7K weekly downloads
- [@tsparticles/effect-bubble](https://npm.io/package/@tsparticles/effect-bubble.md) — 4.6K weekly downloads
- [f3d](https://npm.io/package/f3d.md) — 730 weekly downloads
- [spark-html-motion](https://npm.io/package/spark-html-motion.md) — 298 weekly downloads

## Recent versions

- 3.1.0 (latest) — 2023-04-09
- 4.0.0-beta.1 (beta) — 2026-02-09
- 4.0.0-beta.0 — 2026-02-09
- 3.1.0-beta.1 — 2023-04-09
- 3.0.2 — 2022-06-17
- 3.0.1 — 2022-06-17
- 3.0.0 — 2022-06-17
- 2.0.0 — 2022-05-20
- 2.0.0-beta.1 — 2022-05-20
- 1.3.0 — 2021-02-17
- 1.2.1 — 2021-01-29
- 1.2.0 — 2021-01-29
- 1.1.4 — 2020-12-25
- 1.1.3 — 2020-12-25
- 1.1.2 — 2020-08-04
- … 14 more at https://npm.io/package/react-text-transition/versions

## README

# React-Text-transition

### Animate your text changes

![text-transition](https://raw.githubusercontent.com/WinterCore/react-text-transition/master/example-gifs/example.gif)

[![Edit r03264p26n](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-text-transition-ts-6wp1s7?file=/src/components/App.tsx)

## Installation

`npm install -S react-text-transition`

## Using the demo

`npm run dev`

## How to use

### Example

```javascript
import React from 'react';
import TextTransition, { presets } from 'react-text-transition';

const TEXTS = ['Forest', 'Building', 'Tree', 'Color'];

const App = () => {
  const [index, setIndex] = React.useState(0);

  React.useEffect(() => {
    const intervalId = setInterval(
      () => setIndex((index) => index + 1),
      3000, // every 3 seconds
    );
    return () => clearTimeout(intervalId);
  }, []);

  return (
    <h1>
      <TextTransition springConfig={presets.wobbly}>{TEXTS[index % TEXTS.length]}</TextTransition>
    </h1>
  );
};
```

### Props

| Prop         | Type                | Default                                 | Definition                                                                                              |
| ------------ | ------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| direction    | String (enum)       | 0                                       | Used to determine the direction of the transition `"up"` or `"down"` (Must be an all-lowercase string). |
| inline       | Boolean             | false                                   | Makes the wrapper inline (will auto resize based on contents).                                          |
| delay        | Number              | 0                                       | Delay the transition of the text (in milliseconds).                                                     |
| springConfig | Object              | { mass: 1, tension: 170, friction: 26 } | react-spring's spring configuration.                                                                    |
| className    | String              | ""                                      | Any css classes that you might want to send to the wrapper.                                             |
| style        | React.CSSProperties | {}                                      | Any styles that you might want to send to the wrapper.                                                  |
| children     | React.ReactNode     | REQUIRED                                | The react node to be animated                                                                           |
| translateValue     | string     | "100%"                                | Transform value for determine height animation                                                                           |

---

### Detailed Props

#### inline `Boolean`

Will simply make the wrapper an inline element and animate its width based on currently showing
text, this is useful if you want to show some other static text on the same line.

#### delay `Number`

The amount of miliseconds to wait before transitioning.

#### spring `Object`

react-spring's [Spring configuration](https://www.react-spring.io/docs/hooks/api) (Refer to the
configs section) react-spring's spring presets are exposed as `presets`.

```javascript
import TextTransition, { presets } from 'react-text-transition';

// in your render method
<TextTransition springConfig={presets.wobbly}>{this.state.text}</TextTransition>;
```

You have the following presets

- `default` The default.
- `gentle`
- `wobbly`
- `stiff`
- `slow`
- `molasses`

#### className `String`

Any css classes that you might want to provide to the wrapper.

#### style `React.CSSProperties`

Any css styles that you might want to provide to the wrapper.

## NOTE

Feel free to ask any questions about using this component. This plugin requires
[react](https://www.npmjs.com/package/react) +16.8

---
_Source: https://npm.io/package/react-text-transition · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
