Convert Figma logo to code with AI

plus1tv logoreact-anime

✨ (ノ´ヮ´)ノ*:・゚✧ A super easy animation library for React!

1,546
81
1,546
27

Top Related Projects

49,575

JavaScript animation engine

A spring that solves your animation problems.

✌️ A spring physics based React animation library

23,338

Open source, production-ready animation and gesture library for React

🇨🇭 A React renderer for Three.js

Quick Overview

React-Anime is a React component library for animating React components using the popular Anime.js animation engine. It provides a declarative way to add smooth and powerful animations to React applications, allowing developers to create complex animations with minimal code.

Pros

  • Easy integration with React components
  • Leverages the powerful Anime.js library for smooth and flexible animations
  • Declarative syntax for defining animations
  • Supports a wide range of animation properties and easing functions

Cons

  • Limited documentation and examples
  • Depends on external Anime.js library
  • May have a slight learning curve for those unfamiliar with Anime.js
  • Performance might be affected for complex animations on low-end devices

Code Examples

  1. Basic animation of a single element:
import React from 'react';
import Anime from 'react-anime';

const BasicAnimation = () => (
  <Anime
    opacity={[0, 1]}
    translateY={[-50, 0]}
    duration={1000}
    easing="easeOutElastic"
  >
    <h1>Hello, Animation!</h1>
  </Anime>
);
  1. Animating multiple elements with staggered timing:
import React from 'react';
import Anime from 'react-anime';

const StaggeredAnimation = () => (
  <Anime
    opacity={[0, 1]}
    translateY={[-20, 0]}
    delay={(el, i) => i * 100}
    duration={500}
  >
    <div>Item 1</div>
    <div>Item 2</div>
    <div>Item 3</div>
  </Anime>
);
  1. Using keyframes for more complex animations:
import React from 'react';
import Anime from 'react-anime';

const KeyframeAnimation = () => (
  <Anime
    keyframes={[
      {translateX: 250, scale: 2, rotate: '1turn'},
      {translateX: 0, scale: 1, rotate: '0turn'}
    ]}
    duration={1500}
    easing="easeOutElastic(1, .8)"
    loop={true}
  >
    <div className="box" />
  </Anime>
);

Getting Started

To use React-Anime in your project, follow these steps:

  1. Install the package:

    npm install react-anime animejs
    
  2. Import and use in your React component:

    import React from 'react';
    import Anime from 'react-anime';
    
    const MyComponent = () => (
      <Anime
        opacity={[0, 1]}
        translateY={[-10, 0]}
        duration={1000}
      >
        <div>Animated content</div>
      </Anime>
    );
    
    export default MyComponent;
    
  3. Customize the animation properties as needed, referring to the Anime.js documentation for available options.

Competitor Comparisons

49,575

JavaScript animation engine

Pros of anime

  • Lightweight and versatile JavaScript animation library
  • Can be used with any JavaScript framework or vanilla JS
  • Extensive documentation and examples available

Cons of anime

  • Requires more setup and configuration for React-specific use cases
  • Doesn't provide React-specific optimizations or hooks

Code comparison

anime:

anime({
  targets: '.element',
  translateX: 250,
  rotate: '1turn',
  duration: 800
});

react-anime:

<Anime
  translateX={250}
  rotate="1turn"
  duration={800}
>
  <div className="element" />
</Anime>

Key differences

  • react-anime is specifically designed for React applications
  • anime offers more flexibility for use in various JavaScript environments
  • react-anime provides a more declarative API for React components
  • anime requires manual integration with React components

Use cases

  • Choose anime for non-React projects or when maximum flexibility is needed
  • Opt for react-anime in React applications for easier integration and declarative syntax

Community and maintenance

  • anime has a larger community and more frequent updates
  • react-anime is tailored for React developers but has a smaller user base

A spring that solves your animation problems.

Pros of react-motion

  • More mature and widely adopted in the React community
  • Provides physics-based animations for a more natural feel
  • Offers a declarative API that integrates well with React's philosophy

Cons of react-motion

  • Steeper learning curve due to its physics-based approach
  • May be overkill for simpler animation needs
  • Performance can be an issue with complex animations or many animated elements

Code Comparison

react-motion:

import { Motion, spring } from 'react-motion';

<Motion defaultStyle={{x: 0}} style={{x: spring(100)}}>
  {({x}) => <div style={{transform: `translateX(${x}px)`}} />}
</Motion>

react-anime:

import Anime from 'react-anime';

<Anime easing="easeOutElastic" duration={1000} translateX={100}>
  <div />
</Anime>

Key Differences

  • react-motion uses a physics-based system, while react-anime uses keyframe animations
  • react-anime provides a more straightforward API for common animation scenarios
  • react-motion offers more fine-grained control over animation behavior
  • react-anime is built on top of Anime.js, leveraging its extensive feature set
  • react-motion is a standalone solution specifically designed for React applications

✌️ A spring physics based React animation library

Pros of react-spring

  • More comprehensive animation library with a wider range of features
  • Better performance for complex animations due to its spring-physics based approach
  • Larger community and more frequent updates

Cons of react-spring

  • Steeper learning curve, especially for developers new to spring animations
  • More verbose syntax for simple animations compared to react-anime

Code Comparison

react-spring:

import { useSpring, animated } from 'react-spring'

function AnimatedComponent() {
  const props = useSpring({ opacity: 1, from: { opacity: 0 } })
  return <animated.div style={props}>I will fade in</animated.div>
}

react-anime:

import Anime from 'react-anime'

function AnimatedComponent() {
  return (
    <Anime opacity={[0, 1]}>
      <div>I will fade in</div>
    </Anime>
  )
}

Both libraries offer ways to create animations in React applications, but react-spring provides more control and flexibility at the cost of simplicity. react-anime offers a more straightforward approach for basic animations, making it easier for beginners to get started. However, for complex animations and better performance, react-spring is generally the preferred choice among developers.

23,338

Open source, production-ready animation and gesture library for React

Pros of motion

  • More comprehensive animation and gesture library with a wider range of features
  • Better documentation and community support
  • Seamless integration with Framer Design tool

Cons of motion

  • Larger bundle size, which may impact performance for smaller projects
  • Steeper learning curve due to more complex API and features
  • May be overkill for simple animation needs

Code Comparison

react-anime:

<Anime easing="easeOutElastic" duration={1000} delay={(el, i) => i * 100}>
  <div className="circle"></div>
  <div className="circle"></div>
  <div className="circle"></div>
</Anime>

motion:

<motion.div
  animate={{ scale: 2 }}
  transition={{ duration: 0.5 }}
  whileHover={{ scale: 2.2 }}
  whileTap={{ scale: 1.8 }}
>
  Animated Element
</motion.div>

react-anime is more focused on declarative, group-based animations, while motion offers a more flexible and feature-rich API for individual element animations and interactions. motion provides more advanced features like gestures and layout animations, making it suitable for complex projects. However, react-anime's simpler API may be preferable for basic animation needs and could be easier for beginners to grasp quickly.

Pros of Motion One

  • More comprehensive animation library with support for various animation types (keyframes, springs, etc.)
  • Better performance optimization, especially for complex animations
  • Active development and regular updates

Cons of Motion One

  • Steeper learning curve due to more advanced features
  • Larger bundle size, which may impact load times for smaller projects

Code Comparison

React Anime:

<Anime easing="easeOutElastic" duration={1000} delay={(el, index) => index * 240}>
  <div className="blue"/>
  <div className="green"/>
  <div className="red"/>
</Anime>

Motion One:

import { animate } from "motion"

animate(".box", 
  { x: 100, opacity: 0 },
  { duration: 1, easing: [.22, .03, .26, 1] }
)

Summary

Motion One offers a more robust and performant animation solution, suitable for complex projects. React Anime provides a simpler API, making it easier to use for basic animations in React applications. The choice between the two depends on the project's requirements, with Motion One being more versatile but potentially overkill for simpler use cases.

🇨🇭 A React renderer for Three.js

Pros of react-three-fiber

  • More comprehensive 3D rendering capabilities, allowing for complex 3D scenes and interactions
  • Integrates seamlessly with Three.js, providing access to a wide range of 3D features and tools
  • Active development and large community support, resulting in frequent updates and extensive documentation

Cons of react-three-fiber

  • Steeper learning curve, especially for developers not familiar with 3D graphics concepts
  • Higher performance overhead, potentially impacting application speed for simpler animations
  • Larger bundle size due to the inclusion of Three.js and related dependencies

Code Comparison

react-three-fiber:

import { Canvas } from '@react-three/fiber'

function App() {
  return (
    <Canvas>
      <mesh>
        <boxGeometry args={[1, 1, 1]} />
        <meshStandardMaterial color="hotpink" />
      </mesh>
    </Canvas>
  )
}

react-anime:

import Anime from 'react-anime'

function App() {
  return (
    <Anime easing="easeOutElastic" duration={1000} scale={[0.5, 0.5]}>
      <div className="square" />
    </Anime>
  )
}

The code examples demonstrate the different focus of each library: react-three-fiber for 3D rendering and react-anime for 2D animations. react-three-fiber requires more setup but offers greater flexibility for 3D scenes, while react-anime provides a simpler API for basic animations.

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

react-anime

Npm Package License Unit Tests Coverage Tests Vulnerabilities

(ノ´ヮ´)ノ*:・゚✧ A super easy animation library for React built on top of Julian Garnier's anime.js.
Just place an <Anime> component and what you want animated inside.

Documentation | Demos | Anime.js

Installation

npm i react-anime -S

Features

  • Animate nearly all CSS, SVG, & DOM attributes by adding a prop with their name (eg. opacity, backgroundColor, transform inputs like translateX).

  • Nested animations are as easy as putting an <Anime> component inside another.

  • Cascading animations through delay prop.

  • Add elements dynamically and have them animate in.

  • TypeScript definitions included.

Usage

import Anime, { anime } from 'react-anime';

let colors = [ 'blue', 'green', 'red' ];

const MyAnime = (props) => (
    <Anime delay={anime.stagger(100)} scale={[ 0.1, 0.9 ]}>
        {colors.map((color, i) => <div key={i} className={color} />)}
    </Anime>
);

NPM DownloadsLast 30 Days