12-principles-of-anima…
Audit animation code against Disney's 12 principles adapted for web. Use when reviewing motion, implementing animations, or…
Audit Motion/Framer Motion code for AnimatePresence best practices. Use when reviewing exit animations, modals, or presence state. Outputs file:line findings.
$ npx -y skills add raphaelsalaja/skill --skill mastering-animate-presence --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/mastering-animate-presenceContext preview
The summary Claude sees to decide when to auto-load this skill.
Audit Motion/Framer Motion code for AnimatePresence best practices. Use when reviewing exit animations, modals, or presence state. Outputs file:line findings.
name: mastering-animate-presence description: Audit Motion/Framer Motion code for AnimatePresence best practices. Use when reviewing exit animations, modals, or presence state. Outputs file:line findings. license: MIT metadata: author: raphael-salaja version: "2.0.0" source: /content/mastering-animate-presence/index.mdx
Review Motion code for AnimatePresence and exit animation best practices.
1. Read the specified files (or prompt user for files/pattern) 2. Check against all rules below 3. Output findings in `file:line` format
| Priority | Category | Prefix | |----------|----------|--------| | 1 | Exit Animations | `exit-` | | 2 | Presence Hooks | `presence-` | | 3 | Mode Selection | `mode-` | | 4 | Nested Exits | `nested-` |
Conditional motion elements must be wrapped in AnimatePresence.
**Fail:**
{isVisible && (
<motion.div exit={{ opacity: 0 }} />
)}**Pass:**
<AnimatePresence>
{isVisible && (
<motion.div exit={{ opacity: 0 }} />
)}
</AnimatePresence>Elements inside AnimatePresence should have exit prop defined.
**Fail:**
<AnimatePresence>
{isOpen && (
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} />
)}
</AnimatePresence>**Pass:**
<AnimatePresence>
{isOpen && (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
/>
)}
</AnimatePresence>Dynamic lists inside AnimatePresence must have unique keys.
**Fail:**
<AnimatePresence>
{items.map((item, index) => (
<motion.div key={index} exit={{ opacity: 0 }} />
))}
</AnimatePresence>**Pass:**
<AnimatePresence>
{items.map((item) => (
<motion.div key={item.id} exit={{ opacity: 0 }} />
))}
</AnimatePresence>Exit animation should mirror initial for symmetry.
**Fail:**
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ scale: 0 }}
/>**Pass:**
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 20 }}
/>useIsPresent must be called from child of AnimatePresence, not parent.
**Fail:**
function Parent() {
const isPresent = useIsPresent(); // Wrong location
return (
<AnimatePresence>
{show && <Child />}
</AnimatePresence>
);
}**Pass:**
function Child() {
const isPresent = useIsPresent(); // Correct location
return <motion.div data-exiting={!isPresent} />;
}When using usePresence, always call safeToRemove after async work.
**Fail:**
function AsyncComponent() {
const [isPresent, safeToRemove] = usePresence();
useEffect(() => {
if (!isPresent) {
cleanup(); // Never calls safeToRemove
}
}, [isPresent]);
}**Pass:**
function AsyncComponent() {
const [isPresent, safeToRemove] = usePresence();
useEffect(() => {
if (!isPresent) {
cleanup().then(safeToRemove);
}
}, [isPresent, safeToRemove]);
}Disable interactions on exiting elements using isPresent.
**Fail:**
function Card() {
const isPresent = useIsPresent();
return <button onClick={handleClick}>Click</button>;
// Button clickable during exit
}**Pass:**
function Card() {
const isPresent = useIsPresent();
return (
<button onClick={handleClick} disabled={!isPresent}>
Click
</button>
);
}Mode "wait" nearly doubles animation duration; adjust timing accordingly.
**Fail:**
<AnimatePresence mode="wait">
<motion.div transition={{ duration: 0.3 }} />
</AnimatePresence>
// Total time: ~600ms (too slow)**Pass:**
<AnimatePresence mode="wait">
<motion.div transition={{ duration: 0.15 }} />
</AnimatePresence>
// Total time: ~300ms (acceptable)Mode "sync" causes layout conflicts; position exiting elements absolutely.
**Fail:**
<AnimatePresence mode="sync">
{items.map(item => (
<motion.div exit={{ opacity: 0 }}>{item}</motion.div>
))}
</AnimatePresence>
// Exiting and entering elements compete for space**Pass:**
<AnimatePresence mode="popLayout">
{items.map(item => (
<motion.div exit={{ opacity: 0 }}>{item}</motion.div>
))}
</AnimatePresence>Use popLayout mode for list reordering animations.
**Fail:**
<AnimatePresence>
{items.map(item => <ListItem key={item.id} />)}
</AnimatePresence>
// Layout shifts during exit**Pass:**
<AnimatePresence mode="popLayout">
{items.map(item => <ListItem key={item.id} />)}
</AnimatePresence>Nested AnimatePresence must use propagate prop for coordinated exits.
**Fail:**
<AnimatePresence>
{isOpen && (
<motion.div exit={{ opacity: 0 }}>
<AnimatePresence>
{items.map(item => (
<motion.div key={item.id} exit={{ scale: 0 }} />
))}
</AnimatePresence>
</motion.div>
)}
</AnimatePresence>
// Children vanish instantly when parent exits**Pass:**
<AnimatePresence propagate>
{isOpen && (
<motion.div exit={{ opacity: 0 }}>
<AnimatePresence propagate>
{items.map(item => (
<motion.div key={item.id} exit={{ scale: 0 }} />
))}
</AnimatePresence>
</motion.div>
)}
</AnimatePresence>Parent and child exit durations should be coordinated.
**Fail:**
// Parent exits in 100ms, children in 500ms
<motion.div exit={{ opacity: 0 }} transition={{ duration: 0.1 }}>
<motA skill file based on the articles written on userinterface.wiki. Designed for designers and engineers to help them build better user interfaces.
Audit animation code against Disney's 12 principles adapted for web. Use when reviewing motion, implementing animations, or…
Audit Web Audio API code for sound synthesis best practices. Use when reviewing procedural audio, implementing UI sounds, or…
Build icon components where any icon morphs into any other through SVG line transformation. Use when asked to "create morphing…
Audit CSS for pseudo-element best practices and View Transitions API usage. Use when reviewing hover effects, decorative layers,…
Audit UI code for audio feedback best practices. Use when reviewing sound implementation, checking audio UX decisions, or…
Audit animation code for correct timing function selection. Use when reviewing motion implementations, debugging animations that…