Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Motion Animation Library Guide

Motion Animation Library Guide

Create smooth, performant animations in Google Antigravity applications using Motion with gesture handling and layout animations.

motionanimationreactuxperformance
by antigravity-team
⭐0Stars
.antigravity
# Motion Animation Library Guide

Build engaging, performant animations in your Google Antigravity applications using the Motion library. This guide covers animation fundamentals, gestures, layout animations, and performance optimization.

## Basic Animations

Get started with motion components:

```typescript
// components/AnimatedCard.tsx
"use client";

import { motion } from "motion/react";

export function AnimatedCard({ children }: { children: React.ReactNode }) {
  return (
    <motion.div
      initial={{ opacity: 0, y: 20 }}
      animate={{ opacity: 1, y: 0 }}
      exit={{ opacity: 0, y: -20 }}
      transition={{
        duration: 0.3,
        ease: "easeOut",
      }}
      whileHover={{
        scale: 1.02,
        boxShadow: "0 10px 30px rgba(0,0,0,0.1)",
      }}
      whileTap={{ scale: 0.98 }}
      className="bg-white rounded-xl p-6 border"
    >
      {children}
    </motion.div>
  );
}
```

## Staggered List Animations

Animate lists with staggered children:

```typescript
// components/AnimatedList.tsx
"use client";

import { motion } from "motion/react";

const containerVariants = {
  hidden: { opacity: 0 },
  visible: {
    opacity: 1,
    transition: {
      staggerChildren: 0.1,
      delayChildren: 0.2,
    },
  },
};

const itemVariants = {
  hidden: { opacity: 0, x: -20 },
  visible: {
    opacity: 1,
    x: 0,
    transition: {
      duration: 0.4,
      ease: [0.25, 0.46, 0.45, 0.94],
    },
  },
};

export function AnimatedList<T>({ 
  items, 
  renderItem 
}: {
  items: T[];
  renderItem: (item: T, index: number) => React.ReactNode;
}) {
  return (
    <motion.ul
      variants={containerVariants}
      initial="hidden"
      animate="visible"
      className="space-y-4"
    >
      {items.map((item, index) => (
        <motion.li key={index} variants={itemVariants}>
          {renderItem(item, index)}
        </motion.li>
      ))}
    </motion.ul>
  );
}
```

## Page Transitions

Implement smooth page transitions:

```typescript
// components/PageTransition.tsx
"use client";

import { motion, AnimatePresence } from "motion/react";
import { usePathname } from "next/navigation";

const pageVariants = {
  initial: {
    opacity: 0,
    y: 20,
  },
  enter: {
    opacity: 1,
    y: 0,
    transition: {
      duration: 0.4,
      ease: [0.25, 0.46, 0.45, 0.94],
    },
  },
  exit: {
    opacity: 0,
    y: -20,
    transition: {
      duration: 0.3,
    },
  },
};

export function PageTransition({ children }: { children: React.ReactNode }) {
  const pathname = usePathname();

  return (
    <AnimatePresence mode="wait">
      <motion.div
        key={pathname}
        variants={pageVariants}
        initial="initial"
        animate="enter"
        exit="exit"
      >
        {children}
      </motion.div>
    </AnimatePresence>
  );
}
```

## Layout Animations

Animate layout changes smoothly:

```typescript
// components/ExpandableCard.tsx
"use client";

import { useState } from "react";
import { motion, LayoutGroup, AnimatePresence } from "motion/react";

export function ExpandableCard({ title, content }: { 
  title: string; 
  content: string 
}) {
  const [isExpanded, setIsExpanded] = useState(false);

  return (
    <LayoutGroup>
      <motion.div
        layout
        onClick={() => setIsExpanded(!isExpanded)}
        className="bg-white rounded-xl p-6 cursor-pointer overflow-hidden"
        style={{ borderRadius: 16 }}
      >
        <motion.h3 layout="position" className="text-xl font-bold">
          {title}
        </motion.h3>
        
        <AnimatePresence>
          {isExpanded && (
            <motion.p
              initial={{ opacity: 0, height: 0 }}
              animate={{ opacity: 1, height: "auto" }}
              exit={{ opacity: 0, height: 0 }}
              transition={{ duration: 0.3 }}
              className="mt-4 text-gray-600"
            >
              {content}
            </motion.p>
          )}
        </AnimatePresence>
      </motion.div>
    </LayoutGroup>
  );
}
```

## Gesture Handling

Handle complex gestures:

```typescript
// components/DraggableCard.tsx
"use client";

import { motion, useMotionValue, useTransform } from "motion/react";

export function DraggableCard() {
  const x = useMotionValue(0);
  const rotate = useTransform(x, [-200, 200], [-30, 30]);
  const opacity = useTransform(x, [-200, -100, 0, 100, 200], [0, 1, 1, 1, 0]);
  const background = useTransform(
    x,
    [-200, 0, 200],
    ["#ff6b6b", "#fff", "#51cf66"]
  );

  return (
    <motion.div
      drag="x"
      dragConstraints={{ left: 0, right: 0 }}
      style={{ x, rotate, opacity, background }}
      whileDrag={{ scale: 1.05, cursor: "grabbing" }}
      onDragEnd={(_, info) => {
        if (info.offset.x > 100) {
          console.log("Swiped right - Like!");
        } else if (info.offset.x < -100) {
          console.log("Swiped left - Dismiss");
        }
      }}
      className="w-72 h-96 rounded-2xl shadow-xl cursor-grab"
    />
  );
}
```

## Performance Optimization

Optimize animations for performance:

```typescript
// Use transform properties only (GPU accelerated)
const goodAnimation = {
  scale: 1.1,
  rotate: 10,
  x: 100,
  opacity: 0.5,
};

// Use willChange for complex animations
<motion.div
  style={{ willChange: "transform" }}
  animate={{ scale: [1, 1.2, 1] }}
/>
```

## Best Practices

1. **GPU Acceleration**: Animate transform and opacity properties only
2. **Exit Animations**: Use AnimatePresence for unmount animations
3. **Layout Animations**: Use layout prop for position changes
4. **Reduced Motion**: Respect user preferences with useReducedMotion
5. **Performance**: Profile animations in React DevTools
6. **Semantic Motion**: Use motion to enhance, not distract

When to Use This Prompt

This motion prompt is ideal for developers working on:

  • motion applications requiring modern best practices and optimal performance
  • Projects that need production-ready motion code with proper error handling
  • Teams looking to standardize their motion development workflow
  • Developers wanting to learn industry-standard motion patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their motion implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the motion code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this motion prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For motion projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...