
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
You can enable css-animation and css-transition for react-native easily.
Also works on web.
npm install animatable
Animation will be triggered when specified style prop changed.
When property option is specified behaviour is like css-transition.
import { View } from 'react-native'
import animatable from 'animatable'
const TransitionLeftView = animatable({
property: 'left',
duration: 400,
timingFunction: 'ease-in-out'
})(View)
<TransitionLeftView
onClick={() => this.setState({ on: !this.state.on })}
style={{
position: 'absolute',
left: this.state.on ? 100 : 0,
top: 0,
width: 100,
height: 100,
backgroundColor: 'red'
}}
/>

When keyframes option is specified behaviour is like css-animation.
import { View } from 'react-native'
import animatable from 'animatable'
// define keyframes
const keyframes = {
'0%': { marginLeft: '0%', marginRight: '100%' },
'50%': { marginLeft: '25%', marginRight: '0%' },
'100%': { marginLeft: '100%', marginRight: '0%' }
}
const Bar = animatable({
keyframes: keyframes,
direction: 'alternate-reverse',
duration: 1000,
timingFunction: 'linear',
iterationCount: 'infinite',
})(View)
// render
const Indicator = (props) => (
<View style={{
width: 100,
height: 20,
backgroundColor: 'lightgray'
}}>
<Bar
style={{
height: '100%',
backgroundColor: 'black',
}}
/>
</View>)

const Bar = animatable({
keyframes: {
'0%': { marginLeft: '0%', marginRight: '100%' },
'50%': { marginLeft: '25%', marginRight: '0%' },
'100%': { marginLeft: '100%', marginRight: '0%' }
},
duration: 1000,
// you can set `(prop) => value`
playState: (props) => props.enabled ? 'paused' : 'running'
})(View)
<Bar
onClick={() => this.setState({ enabled: !this.state.enabled })}
enabled={this.state.enabled}
/>
import styled from 'styled-components'
const Bar = styled(animatable({
keyframes: {
'0%': { marginLeft: '0%', marginRight: '100%' },
'50%': { marginLeft: '25%', marginRight: '0%' },
'100%': { marginLeft: '100%', marginRight: '0%' }
},
duration: 1000,
playState: (props) => props.enabled ? 'running': 'paused'
})(View))`
height: 100%;
background-color: black;
`
You have to specify millisec value for duration and delay.
You can use property values same as described on css definitions, and default values are same as css's one of web.
const TransitionComponent = animatable({
// required
property: 'transform',
duration: 200,
// optional
delay: 500,
timingFunction: 'linear'
})(Component)
const AnimationComponent = animatable({
// required
keyframes: {
'0%': { marginLeft: '0%', marginRight: '100%' },
'50%': { marginLeft: '25%', marginRight: '0%' },
'100%': { marginLeft: '100%', marginRight: '0%' }
},
duration: 200,
// optional
delay: 500,
timingFunction: 'linear'
iterationCount: 'infinite',
direction: 'normal',
playState: 'running',
// TODO: fillMode: 'forwards'
})(Component)
https://yusukeshibata.github.io/animatable/
Yusuke Shibata
MIT
FAQs
enable react-native css transition and animation
We found that animatable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.