(null)
return (
)
}
```
---
## Hover Animation
```tsx
import Lottie from "lottie-react"
import { useRef } from "react"
export function HoverAnimation() {
const lottieRef = useRef(null)
return (
lottieRef.current?.play()}
onMouseLeave={() => lottieRef.current?.stop()}
>
)
}
```
---
## Loading Button
```tsx
import Lottie from "lottie-react"
import loadingAnimation from "./loading.json"
import successAnimation from "./success.json"
export function SubmitButton({ onClick }: { onClick: () => Promise }) {
const [state, setState] = useState<"idle" | "loading" | "success">("idle")
const handleClick = async () => {
setState("loading")
await onClick()
setState("success")
setTimeout(() => setState("idle"), 2000)
}
return (
)
}
```
---
## From URL (LottieFiles)
```tsx
import { DotLottieReact } from "@lottiefiles/dotlottie-react"
export function FromUrl() {
return (
)
}
```
---
## Where to Get Animations
| Source | What It Has | Link |
|--------|-------------|------|
| **LottieFiles** | Huge library | lottiefiles.com |
| **IconScout** | Icon animations | iconscout.com/lottie |
| **Motion Elements** | Premium | motionelements.com |
---
## Common Patterns
| Pattern | File to Get |
|---------|-------------|
| Loading spinner | "loading" on LottieFiles |
| Success checkmark | "success check" |
| Error X | "error" |
| Heart like | "heart animation" |
| Confetti | "confetti" |
| Pull to refresh | "pull refresh" |
---
## Performance Tips
1. **Keep JSON small** — Simplify in After Effects
2. **Lazy load** — Don't load on initial render
3. **Stop when hidden** — Use Intersection Observer
4. **Use .lottie format** — More compressed than JSON
---
## Lottie vs Rive
| Feature | Lottie | Rive |
|---------|--------|------|
| Pre-made library | ✅ Huge | Growing |
| State machines | ❌ | ✅ |
| Interactivity | Limited | Full |
| Mouse tracking | ❌ | ✅ |
| Design tool | After Effects | Rive Editor |
| Best for | Static animations | Interactive |
---
## Resources
- **LottieFiles:** https://lottiefiles.com
- **Docs:** https://airbnb.io/lottie
- **React Package:** https://www.npmjs.com/package/lottie-react
---
## Related Skills
- `agents/rive/SKILL.md` — Interactive animations
- `agents/motion/SKILL.md` — React animations
- `agents/micro-interactions/SKILL.md` — UI feedback