Skip to content

adrianmcli/react-reveal-text

Repository files navigation

React Reveal Text

npm dependencies travis bithound license

A small react library for animating the revealing of text.

gif animation

The demo page was built with React Storybook.

Features 🎉

  • Simple – Just plain ol' CSS transition animations.
  • Zero dependencies – Keeping it light and lit up!
  • Flexible – Choose your own easing function and timing.
  • Customizable – Customize and theme like a regular div.
  • Dynamic – Intelligent generation of random transition delay numbers.

Getting Started

  1. Install:
npm install --save react-reveal-text
  1. Use:
<ReactRevealText>WELCOME!</ReactRevealText>

API

Interactive docs with live-editable props here.

This component has many props that you can manipulate; below is a list of all of them.

Note that the component only re-renders when the show property has been changed.

Basic Properties

  • text (string)
    You can set the text either by passing in text as children or by using the text property.

  • show (boolean)
    This prop allows you to control what state the component is in. It allows you to hide or reveal the text.

  • className (string)
    This prop allows you to set the className for the div surrounding the text.

  • style (object)
    This prop allows you to pass in styles for the div surrounding the text.

Transition Properties

Each letter has its own randomly generated delay before its transition begins.

  • transitionTime (integer) [default: 1300]
    The time it takes for each letter's transition.

  • timingFunction (string) [default: 'linear']
    The CSS transition-timing-function property. On this page, you are given a dropdown selection, but in practice (and in the sandbox), you can enter in any valid string.

  • delayMin (integer) [default: 200]
    The minimum allowable delay before the transition for a letter is to begin.

  • delayMax (integer) [default: 1200]
    The maximum allowable delay before the transition for a letter is to begin.

  • threshold (float) [default: 0.2]
    The difference between the random numbers generated for each letter compared to the previous letter. Setting this higher will force the delays to be very different between each letter, spreading out the effect. Setting this lower will allow delays to be similar between letters, sometimes creating a chunking effect.

Contributing

This project was built using my two other tools: React Build Lib and React Build Dist. These tools are still very early in development, so if you are building these libraries, you may encounter some bugs. PRs and issues are welcomed and encouraged! Should probably add some testing too.