Convert Figma logo to code with AI

FormidableLabs logoreact-animations

🎊 A collection of animations for inline style libraries

3,057
159
3,057
12

Top Related Projects

🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.

49,575

JavaScript animation engine

26,486

Animate on scroll library

Animate elements as they scroll into view.

Quick Overview

React Animations is a library that provides a collection of pre-built animations for React components. It offers a simple way to add CSS animations to React applications, allowing developers to easily create engaging and interactive user interfaces.

Pros

  • Easy to use and integrate with existing React projects
  • Provides a wide variety of pre-built animations
  • Lightweight and performant
  • Compatible with CSS-in-JS libraries like styled-components

Cons

  • Limited customization options for animations
  • Requires additional setup for server-side rendering
  • Documentation could be more comprehensive
  • Not actively maintained (last update was in 2019)

Code Examples

Basic usage with styled-components:

import styled, { keyframes } from 'styled-components';
import { bounce } from 'react-animations';

const bounceAnimation = keyframes`${bounce}`;

const BouncyDiv = styled.div`
  animation: 1s ${bounceAnimation};
`;

const App = () => <BouncyDiv>Hello, World!</BouncyDiv>;

Using multiple animations:

import styled, { keyframes } from 'styled-components';
import { merge, tada, wobble } from 'react-animations';

const combinedAnimation = merge(tada, wobble);

const AnimatedDiv = styled.div`
  animation: 2s ${keyframes`${combinedAnimation}`};
`;

const App = () => <AnimatedDiv>Combined Animation</AnimatedDiv>;

Applying animations conditionally:

import styled, { keyframes } from 'styled-components';
import { fadeIn } from 'react-animations';

const fadeInAnimation = keyframes`${fadeIn}`;

const FadeInDiv = styled.div`
  animation: 1s ${props => props.isVisible ? fadeInAnimation : 'none'};
`;

const App = ({ isVisible }) => (
  <FadeInDiv isVisible={isVisible}>Fade In Content</FadeInDiv>
);

Getting Started

  1. Install the package:

    npm install react-animations
    
  2. Import the desired animation and use it with a CSS-in-JS library:

    import styled, { keyframes } from 'styled-components';
    import { fadeIn } from 'react-animations';
    
    const fadeInAnimation = keyframes`${fadeIn}`;
    
    const FadeInDiv = styled.div`
      animation: 1s ${fadeInAnimation};
    `;
    
    const App = () => <FadeInDiv>Fading In</FadeInDiv>;
    
  3. Render your animated component in your React application.

Competitor Comparisons

🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.

Pros of animate.css

  • Lightweight and easy to use with any web project, not limited to React applications
  • Extensive library of pre-built animations, ready to use out of the box
  • Can be applied directly to HTML elements using classes, without additional JavaScript

Cons of animate.css

  • Less flexibility for customizing animations compared to react-animations
  • May require additional JavaScript for more complex animation sequences or timing control
  • Not specifically optimized for React applications, potentially leading to less efficient integration

Code Comparison

animate.css:

<h1 class="animate__animated animate__bounce">An animated element</h1>

react-animations:

import styled, { keyframes } from 'styled-components';
import { bounce } from 'react-animations';

const Bounce = styled.div`animation: 2s ${keyframes`${bounce}`} infinite`;

Summary

animate.css is a versatile, easy-to-use animation library suitable for various web projects, offering a wide range of pre-built animations. It's particularly useful for quick implementation and projects not specifically built with React. On the other hand, react-animations provides more flexibility and integration with React applications, allowing for easier customization and dynamic animation control within the React ecosystem.

49,575

JavaScript animation engine

Pros of anime

  • More versatile, supporting various animation types beyond React
  • Lightweight and performant, with a small file size
  • Extensive documentation and examples

Cons of anime

  • Not specifically designed for React, may require additional setup
  • Learning curve for those familiar with React-specific solutions

Code Comparison

react-animations:

import { fadeIn } from 'react-animations';
import styled, { keyframes } from 'styled-components';

const fadeInAnimation = keyframes`${fadeIn}`;
const FadeInDiv = styled.div`animation: 1s ${fadeInAnimation};`;

anime:

import anime from 'animejs/lib/anime.es.js';

anime({
  targets: '.element',
  opacity: [0, 1],
  duration: 1000,
  easing: 'easeInOutQuad'
});

Summary

anime is a more versatile animation library that can be used across various JavaScript projects, while react-animations is specifically tailored for React applications. anime offers a wider range of animation options and has better performance, but may require more setup in a React environment. react-animations integrates more seamlessly with React and styled-components but is limited to predefined CSS animations. The choice between the two depends on the project requirements and the developer's familiarity with each library.

26,486

Animate on scroll library

Pros of AOS

  • Framework-agnostic, works with any JavaScript project
  • Offers a wider variety of animation options out-of-the-box
  • Simpler implementation for basic scroll-based animations

Cons of AOS

  • Less control over animation timing and sequencing
  • Not specifically optimized for React applications
  • May require more manual DOM manipulation

Code Comparison

AOS:

<div data-aos="fade-up" data-aos-duration="1000">
  Animate me!
</div>

react-animations:

import { fadeIn } from 'react-animations';
import styled, { keyframes } from 'styled-components';

const FadeIn = styled.div`animation: 1s ${keyframes`${fadeIn}`};`;

Key Differences

  • AOS is more suitable for quick, scroll-based animations across various frameworks
  • react-animations integrates better with React's component-based architecture
  • AOS uses data attributes for configuration, while react-animations leverages JavaScript objects
  • react-animations provides more flexibility for custom animations and timing
  • AOS has a larger community and more frequent updates

Use Cases

  • Choose AOS for simple scroll animations in multi-framework projects
  • Opt for react-animations when building complex, React-specific animated interfaces

Animate elements as they scroll into view.

Pros of ScrollReveal

  • More versatile, can be used with any HTML element, not just React components
  • Offers a wider range of animation options, including scroll-based animations
  • Larger community and more frequent updates

Cons of ScrollReveal

  • Not specifically designed for React, may require additional setup
  • Steeper learning curve due to more complex API
  • Larger file size, which may impact page load times

Code Comparison

ScrollReveal:

ScrollReveal().reveal('.element', {
    delay: 200,
    distance: '50px',
    origin: 'bottom',
    duration: 1000
});

react-animations:

import { fadeIn } from 'react-animations';
import styled, { keyframes } from 'styled-components';

const FadeIn = styled.div`animation: 1s ${keyframes`${fadeIn}`}`;

Summary

ScrollReveal offers more flexibility and animation options, making it suitable for a wider range of projects. However, react-animations is more tightly integrated with React and may be easier to use for React-specific projects. ScrollReveal's code is more declarative and configuration-based, while react-animations relies on CSS-in-JS solutions. The choice between the two depends on the specific project requirements, the developer's familiarity with React, and the desired level of animation complexity.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Maintenance Status

react-animations

A collection of animations that can be used with any inline style library that supports using objects to define keyframe animations, such as Radium or Aphrodite. React-animations implements all animations from animate.css.

Check out the interactive demo.

Explore component collection.

Usage

You can import each animation directly from the main package

import { fadeIn } from 'react-animations'

or you can import a specific animation directly

import fadeIn from 'react-animations/lib/fade-in'

Usage with Radium

import React from 'react';
import { bounce } from 'react-animations';
import Radium, {StyleRoot} from 'radium';

const styles = {
  bounce: {
    animation: 'x 1s',
    animationName: Radium.keyframes(bounce, 'bounce')
  }
}

class Test extends React.Component {
  render() {
    <StyleRoot>
      <div className="test" style={styles.bounce}>
      </div>
    </StyleRoot>
  }
}

Usage with Aphrodite

import { bounce } from 'react-animations';
import { StyleSheet, css } from 'aphrodite';

const styles = StyleSheet.create({
  bounce: {
    animationName: bounce,
    animationDuration: '1s'
  }
})

Usage with JSS

import { bounce } from 'react-animations';
import jss from 'jss'
import preset from 'jss-preset-default'

jss.setup(preset())

const {classes} = jss.createStyleSheet({
  '@keyframes bounce': bounce,
  bounce: {
    animationName: 'bounce',
    animationDuration: '1s',
  },
}).attach()

Usage with styled-components

import styled, { keyframes } from 'styled-components';
import { bounce } from 'react-animations';

const bounceAnimation = keyframes`${bounce}`;

const BouncyDiv = styled.div`
  animation: 1s ${bounceAnimation};
`;

Usage with fela-js

import React from 'react';
import { render } from 'react-dom';
import { createRenderer } from 'fela';
import { createComponent, Provider } from 'react-fela';
import { bounce } from 'react-animations';

const mapStylesToProps = ({ background, height, width }, renderer) => ({
	animationName: renderer.renderKeyframe(() => bounce, {}),
	animationDuration: '2s',
	background,
	height,
	width,
});

const BouncingDiv = createComponent(mapStylesToProps, 'div');

render(
	<Provider renderer={createRenderer()}>
		<BouncingDiv background="red" height="100px" width="100px" />
	</Provider>,
	document.getElementById('root'),
);

Animations

Below is a list of all available animations

bounceOut

bounce

bounceIn

bounceInDown

bounceInLeft

bounceInRight

bounceInUp

bounceOutDown

bounceOutLeft

bounceOutRight

bounceOutUp

fadeIn

fadeInDown

fadeInDownBig

fadeInLeft

fadeInLeftBig

fadeInRight

fadeInRightBig

fadeInUp

fadeInUpBig

fadeOut

fadeOutDown

fadeOutDownBig

fadeOutLeft

fadeOutLeftBig

fadeOutRight

fadeOutRightBig

fadeOutUp

fadeOutUpBig

flash

flip

flipInX

flipInY

flipOutX

flipOutY

headShake

hinge

jello

lightSpeedIn

lightSpeedOut

pulse

rollIn

rollOut

rotateIn

rotateInDownLeft

rotateInDownRight

rotateInUpLeft

rotateInUpRight

rotateOut

rotateOutDownLeft

rotateOutDownRight

rotateOutUpLeft

rotateOutUpRight

rubberBand

shake

slideInDown

slideInLeft

slideInRight

slideInUp

slideOutDown

slideOutLeft

slideOutRight

slideOutUp

swing

tada

wobble

zoomIn

zoomInDown

zoomInLeft

zoomInRight

zoomInUp

zoomOut

zoomOutDown

zoomOutLeft

zoomOutRight

zoomOutUp

Merge

react-animations also exports a merge function that takes two animations and returns a new animation that combines the transforms from both. This is experimental and wont work (well) with animations that have conflicting transforms, such as fadeIn and fadeOut. The merged animation can be used just like any of the imported animations.


import { merge, tada, flip } from 'react-animations';
const tadaFlip = merge(tada, flip);

Maintenance Status

Archived: This project is no longer maintained by Formidable. We are no longer responding to issues or pull requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own!

NPM DownloadsLast 30 Days