
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
react-spring
Advanced tools
npm install react-spring
Examples: Interpolation | Native rendering | Reveals | List transitions | Staggered | TodoMVC | DragList
React-spring is a wrapper around a cooked down fork of Facebooks animated. It is trying to bridge Chenglou's React-motion and animated, as both have their pros and cons, but definitively could benefit from one another:
So as you see, they're polar opposites and the strengths of one are the weaknesses of another. React-spring inherits React-motions api while you can feed it everything animated can interpolate. It also has support for animateds efficient native rendering.
(Demo)
Like React-motion by default we'll render the receiving component every frame as it gives you more freedom to animate whatever you like. In many situations this will be ok.
import { Spring } from 'react-spring'
const App = ({ toggle }) => (
<Spring
// Default values, optional ...
from={{ opacity: 0 }}
// Will animate to ...
to={{
// Can be numbers, colors, paths, degrees, percentages, ...
start: toggle ? '#abc' : 'rgb(10,20,30)',
end: toggle ? 'seagreen' : 'rgba(0,0,0,0.5)',
stop: toggle ? '0%' : '50%',
scale: toggle ? 1 : 2,
rotate: toggle ? '0deg' : '45deg',
path: toggle
? 'M20,380 L380,380 L380,380 L200,20 L20,380 Z'
: 'M20,20 L20,380 L380,380 L380,20 L20,20 Z',
}}>
{({ color, scale, rotate, path, start, stop, end }) => (
<div style={{ background: `linear-gradient(to bottom, ${start} ${stop}, ${end} 100%)` }}>
<svg style={{ transform: `scale(${scale}) rotate(${rotate})` }}>
<g><path d={path} /></g>
</svg>
</div>
)}
</Spring>
)
Don't like the way render props wrap your code?
const Header = ({ text, ...styles }) => <h1 style={styles}>{text}</h1>
const App = () => (
<Spring to={{ color: 'red' }} text="extra props are spread over the child" children={Header}/>
)
Et voilà! Now you render a animated version of the Header component! All props that Spring doesn't recognize as its own will be spread over the component, so you can still communicate locals to it. It's actually faster as well since the function isn't recreated on every prop-change.
(Demo)
Pass the native flag for more performance. The animations will be applied to the dom, skipping any React render passes. Just be aware of the following conditions:
animated.[elementName], for instance div becomes animated.divtemplate string literalimport { Spring, animated, template } from 'react-spring'
const App = ({ toggle }) => (
<Spring
native
from={{ fill: 'black' }}
to={{
rotate: toggle ? '0deg' : '180deg',
scale: toggle ? 1 : 2,
path: toggle ? TRIANGLE : RECTANGLE,
}}>
{({ rotate, scale, path }) => (
<animated.svg style={{ transform: template`rotate(${rotate}) scale(${scale})` }}>
<g><animated.path d={path} /></g>
</animated.svg>
)}
</Spring>
)
(Demo)
Use SpringTransition and pass in your keys. from denotes base styles, enter styles are applied when objects appear, leave styles are applied when objects disappear. Keys and children have to match in their order!
import { SpringTransition } from 'react-spring'
const App = ({ items }) => (
<ul>
<SpringTransition
keys={items.map(item => item.key)}
from={{ opacity: 0, color: 'black', height: 0 }}
enter={{ opacity: 1, color: 'red', height: 18 }}
leave={{ opacity: 0, color: 'blue', height: 0 }}>
{items.map(item => styles => <li style={styles}>{item.text}</li>)}
</SpringTransition>
</ul>
)
}
You can use this prototype for two-state reveals, in that case simply render a single child that you can switch out for another.
const App = ({ toggle }) => (
<SpringTransition
keys={toggle ? 'ComponentA' : 'ComponentB'}
from={{ opacity: 0 }}
enter={{ opacity: 1 }}
leave={{ opacity: 0 }}>
{toggle ? ComponentA : ComponentB}
</SpringTransition>
)
(Demo)
Create trailing animations by using SpringTrail. The api is similar to SpringTransition though it will assume your list is fixed. The items will drop in in a trailing motion.
import { SpringTrail } from 'react-spring'
const App = ({ items }) => (
<SpringTrail from={{ opacity: 0 }} to={{ opacity: 1 }} keys={items.map(item => item.key)}>
{items.map(item => styles => (
<div style={styles}>
{item.text}
</div>
))}
</SpringTrail>
)
Framer Motion is a popular animation library for React that provides a simple API for creating animations and gestures. It is known for its ease of use and powerful features, such as layout animations and shared element transitions. Compared to react-spring, Framer Motion is more focused on providing a high-level API for common animation tasks, while react-spring offers more flexibility and control over the animation physics.
React Transition Group is a low-level animation library for React that provides more control over the transition states of components. It is often used for simple animations like fading, sliding, and collapsing. Compared to react-spring, React Transition Group is more focused on managing the lifecycle of animations and transitions, while react-spring provides more advanced physics-based animations.
React Move is an animation library for React that allows you to create complex animations using a declarative syntax. It is designed to work well with data-driven animations and provides a flexible API for creating custom animations. Compared to react-spring, React Move is more focused on data-driven animations and provides a different approach to defining animations using a declarative syntax.
FAQs
Unknown package
The npm package react-spring receives a total of 726,632 weekly downloads. As such, react-spring popularity was classified as popular.
We found that react-spring demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.