Chakra UI Animations is a dependancy which offers you pre-built animations for your Chakra UI components.
yarn add @codechem/chakra-ui-animations
# or
npm i @codechem/chakra-ui-animations
import { useAnimation } from '@codechem/chakra-ui-animations';
function App() {
const animation = useAnimation('flip', { duration: 2000, iterationCount: 'infinite' });
return (
<Box bg="red.500" h="500px" w="500px" animation={animation}>
<Heading>
Open source rocks!
</Heading>
</Box>
)
}
duration
- is the length of the animation (in miliseconds)iterationCount
- is the amount of times the you want the animation to repeat (number or'infinite'
)
The first parameter in the useAnimation
hook is the animation name, this is the list for all animations:
- bounce-in
- bounce
- flash
- flip
- head-shake
- heart-beat
- jello
- pulse
- rotate-9
- rotate-scale
- rubber-band
- shake-x
- shake-y
- shake
- swing
- tada
- wobble
- shadow-drop-2
- shadow-drop
- shadow-inset
- hinge
- jack-in-the-box
- roll-in
- roll-out