When adding motion to a web UI, two tools dominate: CSS animations and Lottie. Both are capable, but they serve different use cases.
What Is a CSS Animation?
CSS animations use keyframes in your stylesheet to transition between property values. No libraries, no extra assets — just the browser.
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.loader { animation: spin 1s linear infinite; }
CSS animations are perfect for simple transitions, loading spinners, hover effects, and anything expressible in CSS properties.
What Is a Lottie Animation?
Lottie is a JSON-based animation format exported from Adobe After Effects. It renders complex motion paths, morphing shapes, and multi-layer compositions — things CSS cannot do.
lottie.loadAnimation({
container: document.getElementById("anim"),
renderer: "svg",
loop: true,
autoplay: true,
path: "/animations/success.json"
});
When to Use CSS Animations
CSS is the right choice when the animation is simple (fade, slide, scale, rotate), when you want zero JavaScript, when performance is critical (CSS animations run on the compositor thread), or when you need :hover/:focus triggers.
Best for: loading spinners, button hovers, skeleton screens, progress bars, page transitions.
When to Use Lottie
Lottie wins when the animation was designed in After Effects, involves complex paths or masks, requires pixel-perfect fidelity to a brand asset, or needs programmatic control (play, pause, scrub, speed).
Best for: onboarding illustrations, empty states, success/error confirms, animated logos, hero animations.
Quick Comparison
| Feature | CSS Animation | Lottie |
|---|---|---|
| Extra file size | 0 KB | 10–200 KB JSON |
| JS required | No | ~100 KB runtime |
| Designer handoff | CSS code | .json / .lottie file |
| Complexity | Simple transforms | Full After Effects motion |
| Programmatic control | Via classList | Full API |
Free Tools for Lottie
If you go the Lottie route, you need a .json file. IconKing is a free browser-based Lottie preview, editor, and format converter — no sign-up needed. Use it to test animations before dropping them into your project.
The Verdict
Use CSS for simple, stateless UI polish. Use Lottie when a designer hands you a file or when the animation is complex enough that CSS would take hundreds of lines to approximate.
Most production apps use both: CSS for micro-interactions, Lottie for hero and empty-state moments. Pick the right tool per job.
Top comments (0)