Back to React Spring

README

packages/react-spring/README.md

10.0.33.4 KB
Original Source
<p align="center"> </p> <h1 align="center">react-spring</h1> <h3 align="center">A spring-physics first animation library giving you flexible tools to confidently cast your ideas</h3> <p align="center"> <a href="https://www.npmjs.com/package/react-spring" target="_blank"> </a> <a href="https://www.npmjs.com/package/react-spring" target="_blank"> </a> <a href="https://discord.gg/ZZjjNvJ" target="_blank"> </a> </p>

react-spring is a cross-platform spring-physics first animation library.

It's as simple as:

jsx
const styles = useSpring({
  from: {
    opacity: 0
  },
  to: {
    opacity: 1
  }
})

<animated.div style={styles} />

Just a small bit about us:

  • Cross-Platform: We support react-dom, react-native, react-three-fiber, react-konva & react-zdog.
  • Versatile: Be declarative with your animations or if you prefer, imperative.
  • Spring-Physics First: By default animation use springs for fluid interactivity, but we support durations with easings as well.

There's a lot more to be had! Give it a try and find out.

Getting Started

⚡️ Jump Start

shell
# Install the entire library
npm install react-spring
# or just install your specific target (recommended)
npm install @react-spring/web
jsx
import { animated, useSpring } from '@react-spring/web'

const FadeIn = ({ isVisible, children }) => {
  const styles = useSpring({
    opacity: isVisible ? 1 : 0,
    y: isVisible ? 0 : 24,
  })

  return <animated.div style={styles}>{children}</animated.div>
}

It's as simple as that to create scroll-in animations when value of isVisible is toggled.

📖 Documentation and Examples

More documentation on the project can be found here.

Pages contain their own examples which you can check out there, or open in codesandbox for a more in-depth view!


📣 What others say

<p align="middle"> </p>

Used by

<p align="middle"> <a href="https://nextjs.org/"></a> <a href="https://codesandbox.io/"></a> <a href="https://aragon.org/"></a> </p>

And many others...

Backers

Thank you to all our backers! 🙏 If you want to join them here, then consider contributing to our Opencollective.

<a href="https://opencollective.com/react-spring#backers" target="_blank"> </a>

Contributors

This project exists thanks to all the people who contribute.

<a href="https://github.com/react-spring/react-spring/graphs/contributors"> </a>