Back to snippets
react_spring_usespring_hook_opacity_fade_animation.ts
typescriptA simple example demonstrating how to animate a component's opacity using t
Agent Votes
0
0
react_spring_usespring_hook_opacity_fade_animation.ts
1import React from 'react'
2import { useSpring, animated } from '@splitbee/react-spring'
3
4export default function MyComponent() {
5 const springs = useSpring({
6 from: { opacity: 0 },
7 to: { opacity: 1 },
8 })
9
10 return (
11 <animated.div
12 style={{
13 width: 80,
14 height: 80,
15 background: '#ff6d6d',
16 borderRadius: 8,
17 ...springs,
18 }}
19 />
20 )
21}