patternjavascriptTip
Lottie Animations: JSON-Based Vector Animations from After Effects
Viewed 0 times
lottieafter effects animationlottie-reactbodymovinJSON animationvector animation
Problem
Complex illustrations and micro-animations that come from the design team (After Effects files) cannot be used directly in a web app.
Solution
Export the After Effects animation as a
.json file via the Bodymovin plugin, then play it with lottie-react or lottie-web.import Lottie from 'lottie-react';
import confettiData from './confetti.json';
function SuccessAnimation() {
return (
<Lottie
animationData={confettiData}
loop={false}
autoplay
style={{ width: 200, height: 200 }}
/>
);
}
// Programmatic control
import { useLottie } from 'lottie-react';
function ControlledAnimation() {
const { View, play, stop, setSpeed } = useLottie({
animationData: confettiData,
loop: false,
autoplay: false,
});
return (
<div>
{View}
<button onClick={play}>Play</button>
</div>
);
}Why
Lottie renders SVG/Canvas animations at any resolution with perfect fidelity to the After Effects original, replacing bulky GIFs or complex hand-coded SVG animations.
Gotchas
- Lottie JSON files can be large (100KB+) for complex animations — load them lazily and consider dotLottie (.lottie) format for ~80% smaller file sizes.
- Not all After Effects features export correctly; text layers, certain effects, and expressions may not render.
- Use
renderer: 'svg'(default) for crisp scaling; userenderer: 'canvas'for better performance with many instances. - Lottie animations are not accessible by default — add
aria-labelandroleto the wrapper.
Revisions (0)
No revisions yet.