Auto Animate
Zero-config animation library by FormKit — automatic transitions for DOM additions, removals, and reordering with a single function call or directive.
You are an expert in Auto-Animate for adding smooth transitions to web applications with minimal code.
## Key Points
- Only direct children of the animated parent are tracked. Nest another `autoAnimate` call for deeper levels.
- Always provide stable `key` props in frameworks so the library can distinguish moves from add/remove pairs.
- Keep animated containers simple — avoid mixing animated children with absolutely-positioned overlays inside the same parent.
- Applying `autoAnimate` to a container with `display: contents` or `display: inline` breaks coordinate tracking since those elements have no box model.
- In React, forgetting to spread the `ref` onto the parent element means nothing animates, with no error thrown.
## Quick Example
```bash
npm install @formkit/auto-animate
```
```js
import autoAnimate from "@formkit/auto-animate";
const parent = document.getElementById("list");
autoAnimate(parent);
```skilldb get animation-services-skills/Auto AnimateFull skill: 151 linesAuto-Animate — Web Animation
You are an expert in Auto-Animate for adding smooth transitions to web applications with minimal code.
Core Philosophy
Overview
Auto-Animate is a lightweight (2KB) library by FormKit that watches a parent element and automatically animates its direct children when they are added, removed, or reordered in the DOM. It works with any framework (React, Vue, Svelte, Solid) or vanilla JS. The core idea is zero-configuration: call autoAnimate(parentElement) and all child transitions just work.
Setup & Configuration
npm install @formkit/auto-animate
Vanilla JavaScript
import autoAnimate from "@formkit/auto-animate";
const parent = document.getElementById("list");
autoAnimate(parent);
React
import { useAutoAnimate } from "@formkit/auto-animate/react";
function TodoList({ items }) {
const [parent] = useAutoAnimate();
return (
<ul ref={parent}>
{items.map((item) => (
<li key={item.id}>{item.text}</li>
))}
</ul>
);
}
Vue
<script setup>
import { useAutoAnimate } from "@formkit/auto-animate/vue";
const [parent] = useAutoAnimate();
</script>
<template>
<ul ref="parent">
<li v-for="item in items" :key="item.id">{{ item.text }}</li>
</ul>
</template>
Vue also supports a v-auto-animate directive via a plugin:
import { autoAnimatePlugin } from "@formkit/auto-animate/vue";
app.use(autoAnimatePlugin);
<ul v-auto-animate>
<li v-for="item in items" :key="item.id">{{ item.text }}</li>
</ul>
Core Patterns
Custom Duration and Easing
autoAnimate(parent, {
duration: 300,
easing: "ease-in-out",
});
Disabling and Re-enabling
const [parent, enable] = useAutoAnimate();
// Toggle animations
enable(false); // disable
enable(true); // re-enable
Custom Animation with a Keyframe Function
autoAnimate(parent, (el, action, oldCoords, newCoords) => {
let keyframes;
if (action === "add") {
keyframes = [
{ opacity: 0, transform: "scale(0.8)" },
{ opacity: 1, transform: "scale(1)" },
];
} else if (action === "remove") {
keyframes = [
{ opacity: 1, transform: "scale(1)" },
{ opacity: 0, transform: "scale(0.8)" },
];
} else if (action === "remain" && oldCoords && newCoords) {
const dx = oldCoords.left - newCoords.left;
const dy = oldCoords.top - newCoords.top;
keyframes = [
{ transform: `translate(${dx}px, ${dy}px)` },
{ transform: "translate(0, 0)" },
];
}
return new Animation(
new KeyframeEffect(el, keyframes, { duration: 250, easing: "ease-out" }),
);
});
Best Practices
- Only direct children of the animated parent are tracked. Nest another
autoAnimatecall for deeper levels. - Always provide stable
keyprops in frameworks so the library can distinguish moves from add/remove pairs. - Keep animated containers simple — avoid mixing animated children with absolutely-positioned overlays inside the same parent.
Common Pitfalls
- Applying
autoAnimateto a container withdisplay: contentsordisplay: inlinebreaks coordinate tracking since those elements have no box model. - In React, forgetting to spread the
refonto the parent element means nothing animates, with no error thrown.
Anti-Patterns
Using the service without understanding its pricing model. Cloud services bill differently — per request, per GB, per seat. Deploying without modeling expected costs leads to surprise invoices.
Hardcoding configuration instead of using environment variables. API keys, endpoints, and feature flags change between environments. Hardcoded values break deployments and leak secrets.
Ignoring the service's rate limits and quotas. Every external API has throughput limits. Failing to implement backoff, queuing, or caching results in dropped requests under load.
Treating the service as always available. External services go down. Without circuit breakers, fallbacks, or graceful degradation, a third-party outage becomes your outage.
Coupling your architecture to a single provider's API. Building directly against provider-specific interfaces makes migration painful. Wrap external services in thin adapter layers.
Install this skill directly: skilldb add animation-services-skills
Related Skills
Anime.js
Lightweight JavaScript animation engine — DOM, CSS, SVG, and object property animations with timeline sequencing, staggering, and spring-based easing.
Framer Motion (Motion)
Production-grade animation library for React — animate, variants, AnimatePresence, layout animations, gestures, scroll-triggered effects, useMotionValue, and stagger orchestration.
GSAP
GreenSock Animation Platform — timeline orchestration, ScrollTrigger, tweens, stagger, React integration with useGSAP, SplitText, morphSVG, and from/to/fromTo patterns.
Lottie
Render After Effects animations on the web with lottie-react and lottie-web — player controls, interactivity, lazy loading, and the light player for optimized bundles.
Motion One
Lightweight Web Animations API wrapper — animate, timeline, spring physics, scroll-linked animations, stagger, and minimal bundle size for modern browsers.
Popmotion
Functional animation library — spring physics, decay, keyframe interpolation, and composable animation primitives that power Framer Motion's internals.