code/tamagui.dev/data/docs/core/animations-reanimated.mdx
Reanimated is an animation library that targets React Native and React Native Web. It runs animations off-thread and provides smooth spring and timing animations.
yarn add @tamagui/animations-reanimated react-native-reanimated
Follow the Reanimated installation guide to complete setup for your platform.
Add your animations to your Tamagui config:
import { createAnimations } from '@tamagui/animations-reanimated'
import { createTamagui } from 'tamagui'
export default createTamagui({
animations: createAnimations({
fast: {
type: 'spring',
damping: 20,
mass: 1.2,
stiffness: 250,
},
medium: {
type: 'spring',
damping: 10,
mass: 0.9,
stiffness: 100,
},
slow: {
type: 'spring',
damping: 20,
stiffness: 60,
},
}),
// ...
})
At runtime, this driver parses animatable style properties and hands them over to Reanimated using worklets. Animations run on the UI thread for smooth 60fps performance.
Reanimated animations support both spring and timing (tween) animations:
{
type: 'spring',
damping: 10, // Higher = less bouncy
mass: 0.9, // Higher = more inertia
stiffness: 100, // Higher = faster
}
{
type: 'timing',
duration: 300, // Duration in milliseconds
}
You can add animation delays using the array syntax:
<Square transition={['bouncy', { delay: 200 }]} />
The delay is specified in milliseconds.
Advantages:
Considerations:
You can use Reanimated on native and a lighter driver on web:
// animations.native.ts
import { createAnimations } from '@tamagui/animations-reanimated'
export const animations = createAnimations({
bouncy: {
type: 'spring',
damping: 10,
stiffness: 100,
},
})
// animations.ts (web)
import { createAnimations } from '@tamagui/animations-motion'
export const animations = createAnimations({
bouncy: {
type: 'spring',
damping: 10,
stiffness: 100,
},
})
Then import without the extension:
import { animations } from './animations'
import { createAnimations } from '@tamagui/animations-reanimated'
import { YStack, createTamagui } from 'tamagui'
const animations = createAnimations({
bouncy: {
type: 'spring',
damping: 10,
mass: 0.9,
stiffness: 100,
},
quick: {
type: 'spring',
damping: 20,
mass: 1.2,
stiffness: 250,
},
})
export default createTamagui({
animations,
// ... rest of config
})
// Usage in components
export const MyComponent = () => (
<YStack
transition="bouncy"
enterStyle={{
opacity: 0,
scale: 0.9,
}}
/>
)
The Reanimated driver now works with Tamagui to bypasses all internal style changes to instead directly hand off to Reanimated worklets.
Reanimated provides advanced features:
See the Reanimated documentation for more details.