auto-animate
Production-tested setup for AutoAnimate (@formkit/auto-animate) - a zero-config, drop-in animation library that automatically adds smooth transitions when DOM elements are added, removed, or moved. This skill should be used when building UIs that need simple, automatic animations for lists, accordions, toasts, or form validation messages without the complexity of full animation libraries. Use when: Adding smooth animations to dynamic lists, building filter/sort interfaces, creating accordion components, implementing toast notifications, animating form validation messages, needing simple transitions without animation code, working with Vite + React + Tailwind, deploying to Cloudflare Workers Static Assets, or encountering SSR errors with animation libraries. Keywords: auto-animate, @formkit/auto-animate, formkit, zero-config animation, automatic animations, drop-in animation, list animations, accordion animation, toast animation, form validation animation, lightweight animation, 2kb animation, prefers-reduced-motion, accessible animations, vite react animation, cloudflare workers animation, ssr safe animation
NPX Install
npx skill4agent add jackspace/claudeskillz auto-animateTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →AutoAnimate
Quick Start (2 Minutes)
1. Install AutoAnimate
pnpm add @formkit/auto-animate- Only 3.28 KB gzipped (vs 22 KB for Motion)
- Zero dependencies
- Framework-agnostic (React, Vue, Svelte, vanilla JS)
2. Add to Your Component
import { useAutoAnimate } from "@formkit/auto-animate/react";
export function MyList() {
const [parent] = useAutoAnimate(); // 1. Get ref
return (
<ul ref={parent}> {/* 2. Attach to parent */}
{items.map(item => (
<li key={item.id}>{item.text}</li> {/* 3. That's it! */}
))}
</ul>
);
}- ✅ Always use unique, stable keys for list items
- ✅ Parent element must always be rendered (not conditional)
- ✅ AutoAnimate respects automatically
prefers-reduced-motion - ✅ Works on add, remove, AND reorder operations
3. Use in Production (SSR-Safe)
// Use client-only import to prevent SSR errors
import { useState, useEffect } from "react";
export function useAutoAnimateSafe<T extends HTMLElement>() {
const [parent, setParent] = useState<T | null>(null);
useEffect(() => {
if (typeof window !== "undefined" && parent) {
import("@formkit/auto-animate").then(({ default: autoAnimate }) => {
autoAnimate(parent);
});
}
}, [parent]);
return [parent, setParent] as const;
}Known Issues Prevention
Issue #1: SSR/Next.js Import Errors
templates/vite-ssr-safe.tsxIssue #2: Conditional Parent Rendering
// ❌ Wrong
{showList && <ul ref={parent}>...</ul>}
// ✅ Correct
<ul ref={parent}>{showList && items.map(...)}</ul>Issue #3: Missing Unique Keys
key={item.id}Issue #4: Flexbox Width Issues
flex-grow: 1Issue #5: Table Row Display Issues
<tbody>Issue #6: Jest Testing Errors
moduleNameMapperIssue #7: esbuild Compatibility
Issue #8: CSS Position Side Effects
position: relativeIssue #9: Vue/Nuxt Registration Errors
Issue #10: Angular ESM Issues
When to Use AutoAnimate vs Motion
Use AutoAnimate When:
- ✅ Simple list transitions (add/remove/sort)
- ✅ Accordion expand/collapse
- ✅ Toast notifications fade in/out
- ✅ Form validation messages appear/disappear
- ✅ Zero configuration preferred
- ✅ Small bundle size critical (3.28 KB)
- ✅ Applying to existing/3rd-party code
- ✅ "Good enough" animations acceptable
Use Motion When:
- ✅ Complex choreographed animations
- ✅ Gesture controls (drag, swipe, hover)
- ✅ Scroll-based animations
- ✅ Spring physics animations
- ✅ SVG path animations
- ✅ Keyframe control needed
- ✅ Animation variants/orchestration
- ✅ Custom easing curves
Critical Rules
Always Do
key={item.id}key={index}disrespectUserMotionPreference: falseNever Do
{show && <ul ref={parent}>}key={index}disrespectUserMotionPreference: trueConfiguration
import { useAutoAnimate } from "@formkit/auto-animate/react";
const [parent] = useAutoAnimate({
duration: 250, // milliseconds (default: 250)
easing: "ease-in-out", // CSS easing (default: "ease-in-out")
// disrespectUserMotionPreference: false, // Keep false!
});Using Bundled Resources
Templates (templates/)
- - Simple list with add/remove/shuffle
react-basic.tsx - - Typed setup with custom config
react-typescript.tsx - - Animated filtering and sorting
filter-sort-list.tsx - - Expandable sections
accordion.tsx - - Fade in/out messages
toast-notifications.tsx - - Error messages animation
form-validation.tsx - - Cloudflare Workers/SSR pattern
vite-ssr-safe.tsx
References (references/)
- - Decision guide for which to use
auto-animate-vs-motion.md - - Flexbox, table, and position gotchas
css-conflicts.md - - Next.js, Nuxt, Workers workarounds
ssr-patterns.md
Scripts (scripts/)
- - Automated setup script
init-auto-animate.sh
Cloudflare Workers Compatibility
export default defineConfig({
plugins: [react(), cloudflare()],
ssr: {
external: ["@formkit/auto-animate"],
},
});Accessibility
prefers-reduced-motion/* User's system preference */
@media (prefers-reduced-motion: reduce) {
/* AutoAnimate disables animations automatically */
}disrespectUserMotionPreference: trueOfficial Documentation
- Official Site: https://auto-animate.formkit.com
- GitHub: https://github.com/formkit/auto-animate
- npm: https://www.npmjs.com/package/@formkit/auto-animate
- React Docs: https://auto-animate.formkit.com/react
- Video Tutorial: Laracasts video (see README)
Package Versions (Verified 2025-11-07)
{
"dependencies": {
"@formkit/auto-animate": "^0.9.0"
},
"devDependencies": {
"react": "^19.2.0",
"vite": "^6.0.0"
}
}Production Example
- Bundle Size: 3.28 KB gzipped
- Setup Time: 2 minutes (vs 15 min with Motion)
- Errors: 0 (all 10 known issues prevented)
- Validation: ✅ Works with Vite, Tailwind v4, Cloudflare Workers, React 19
- ✅ Filter/sort lists
- ✅ Accordion components
- ✅ Toast notifications
- ✅ Form validation messages
- ✅ SSR/Cloudflare Workers
- ✅ Accessibility (prefers-reduced-motion)
Troubleshooting
Problem: Animations not working
- Is parent element always in DOM? (not conditional)
- Do items have unique, stable keys?
- Is ref attached to immediate parent of animated children?
Problem: SSR/Next.js errors
useEffect(() => {
if (typeof window !== "undefined") {
import("@formkit/auto-animate").then(({ default: autoAnimate }) => {
autoAnimate(parent);
});
}
}, [parent]);Problem: Items flash instead of animating
key={item.id}key={index}Problem: Flexbox width issues
flex-grow: 1Problem: Table rows don't animate
<tbody><tr>Complete Setup Checklist
- Installed
@formkit/auto-animate@0.9.0 - Using React 19+ (or Vue/Svelte)
- Added ref to parent element
- Parent element always rendered (not conditional)
- List items have unique, stable keys
- Tested with
prefers-reduced-motion - SSR-safe if using Cloudflare Workers/Next.js
- No flexbox width issues
- Dev server runs without errors
- Production build succeeds
- Check for working examples
templates/ - Check for library comparison
references/auto-animate-vs-motion.md - Check for SSR workarounds
references/ssr-patterns.md - Check official docs: https://auto-animate.formkit.com
- Check GitHub issues: https://github.com/formkit/auto-animate/issues