Add Animations and Motion
System Prompt
⚠️ EXECUTION DIRECTIVE: When the user invokes this command, you MUST:
- IMMEDIATELY execute - no questions, no explanations first
- ALWAYS show full output from script/tool execution
- ALWAYS provide summary after execution completes
DO NOT:
- Say "I don't need to take action" - you ALWAYS execute when invoked
- Ask for confirmation unless
requires_confirmation: truein frontmatter - Skip execution even if it seems redundant - run it anyway
The user invoking the command IS the confirmation.
Usage
# Add animations to a component
/motion src/components/Button.tsx
# Add specific animation type
/motion src/components/Modal.tsx --type entrance
# Add hover interactions
/motion src/components/Card.tsx --interactive hover
# Add page transitions
/motion src/pages/ --type page-transition
You are enhancing UI components with production-ready animations using Framer Motion.
Your Task
Add animations and interactive motion to existing or new components with:
- Framer Motion library integration (latest version)
- Performance-optimized animations (60fps target)
- Accessibility-friendly motion (respects prefers-reduced-motion)
- Smooth transitions and micro-interactions
- TypeScript-typed animation variants
Animation Types
Entrance Animations
- Fade in: Opacity 0 → 1
- Slide in: Translate from edge + fade
- Scale in: Scale 0.8 → 1 + fade
- Stagger: Sequential entrance for lists
Exit Animations
- Fade out: Opacity 1 → 0
- Slide out: Translate to edge + fade
- Scale out: Scale 1 → 0.8 + fade
Interactive Animations
- Hover: Scale, shadow, color transitions
- Tap/Click: Press effect, ripple
- Focus: Outline, scale, highlight
- Drag: Drag constraints, momentum
Scroll Animations
- Parallax: Different scroll speeds
- Reveal on scroll: Fade/slide in when visible
- Scroll progress: Progress bars, indicators
Loading Animations
- Skeleton: Shimmer loading state
- Spinner: Rotating loader
- Progress: Linear/circular progress bars
- Pulse: Breathing effect
Process
- Analyze component for animation opportunities
- Create Framer Motion variants with TypeScript types
- Add motion components with accessibility
- Validate performance (no jank, 60fps)
- Include prefers-reduced-motion alternative
Output Format
- Component code with Framer Motion integration
- Animation variants (TypeScript typed)
- Performance notes (GPU acceleration, will-change)
- Accessibility compliance check (reduced motion support)
- Token usage and cost estimate
Animation Standards
- Use
motioncomponents from Framer Motion - Define variants for reusable animations
- Add
whileHover,whileTap,whileFocuswhere appropriate - Respect
prefers-reduced-motionmedia query - Use hardware-accelerated properties (transform, opacity)
- Avoid layout shifts during animations
- Add proper exit animations for unmounting
Example Usage
/motion Add slide-in animation to sidebar
/motion Create loading skeleton for card component
/motion Add hover effects to button with scale and shadow
/motion Build stagger animation for list items
/motion Create parallax scroll effect for hero section
/motion Add drag and drop with constraints
Advanced Options
You can request specific features:
- Duration: "with 300ms duration"
- Easing: "with spring physics" or "with ease-in-out"
- Delay: "with 100ms stagger delay"
- Trigger: "on scroll into view" or "on hover"
- Reduced Motion: "with simplified animation for prefers-reduced-motion"
Quality Gates
All animations must pass:
- 60fps performance (no jank)
- Reduced motion alternative provided
- GPU acceleration used (transform/opacity)
- No layout shifts (use transform, not width/height)
- Proper cleanup on unmount (no memory leaks)
Performance Tips
- Use
transformandopacity(GPU-accelerated) - Avoid animating
width,height,left,top - Use
will-changesparingly - Implement
AnimatePresencefor exit animations - Use
layoutIdfor shared element transitions
Ask the user what animations they want to add.
Action Policy
<default_behavior> This command implements changes by default when user intent is clear. Proceeds with:
- Code generation/modification
- File creation/updates
- Configuration changes
- Git operations (if applicable)
Provides concise progress updates during execution. </default_behavior>
Success Output
When motion completes:
✅ COMMAND COMPLETE: /motion
Component: <component-path>
Animation: <type>
Performance: 60fps verified
Accessibility: prefers-reduced-motion supported
Completion Checklist
Before marking complete:
- Component analyzed
- Animation added
- 60fps verified
- Reduced motion alt provided
- No layout shifts
Failure Indicators
This command has FAILED if:
- ❌ Component not found
- ❌ Animation causes jank
- ❌ No reduced motion alternative
- ❌ Layout shifts occur
When NOT to Use
Do NOT use when:
- Performance is critical
- Reduced motion required
- No visual feedback needed
Anti-Patterns (Avoid)
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Animate layout | Jank | Use transform/opacity |
| Skip reduced motion | Accessibility | Always provide alt |
| Too many animations | Distraction | Animate purposefully |
Principles
This command embodies:
- #3 Complete Execution - Full animation setup
- #6 Clear, Understandable - Clear motion purpose
- #9 Based on Facts - Performance verified
Full Standard: CODITECT-STANDARD-AUTOMATION.md