Communitygithub.com

Motion (Framer Motion) — React UI-Animationsbibliothek

Deklarative Animationen für React. Federn, Gesten, Layout-Animationen und Seitenübergänge. GPU-beschleunigt, produktionsreif.

Was ist Motion (Framer Motion) — React UI-Animationsbibliothek?

Diese Fähigkeit (Skill) bietet eine umfassende Einführung in Motion (ehemals Framer Motion), eine leistungsstarke, deklarative UI-Animationsbibliothek für React. Entwickler können damit mühelos Animationen, Gesten, Layout-Übergänge und Seitenwechsel mit GPU-beschleunigter Performance implementieren. Der Skill deckt die Kern-API ab, darunter die Animation von Komponenten beim Ein- und Ausblenden (mount/unmount) mit `AnimatePresence`, die Verwendung von Feder-Physik für natürliche Bewegungen, die Orchestrierung komplexer Animationen mit `variants` (einschließlich Staffelung von Kindern), sowie die Integration von Gesten wie Hover, Tap und Drag. Darüber hinaus werden Layout-Animationen (`layout`), Scroll-basierte Animationen mit `useScroll` und `useTransform`, die imperative Steuerung mittels `useAnimate` und die Definition von Keyframe-Sequenzen behandelt. Die Beschreibung enthält Best Practices, einen Vergleich mit GSAP und praktische Codebeispiele für gängige Szenarien wie Seitenübergänge oder gestaffelte Listen. Entwickler, die mit Claude Code, Cursor oder Codex arbeiten, können diese Fähigkeit nutzen, um schnelle und konsistente Animationen in ihren React-Projekten zu erstellen.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ever-just/agentskills/tree/HEAD/skills/framer-motion

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Was macht Motion (Framer Motion) — React UI-Animationsbibliothek?

Deklarative Animationen für React. Federn, Gesten, Layout-Animationen und Seitenübergänge. GPU-beschleunigt, produktionsreif.

Übersicht

  • Repository: github.com/motiondivision/motion (26K+ Sterne)
  • Sprache: TypeScript / React
  • Lizenz: MIT
  • Installation: npm install motion
  • Dokumentation: motion.dev
  • Hinweis: Framer Motion wurde zu Motion umbenannt. Importiere von motion/react.

Kern-API

Einfache Animation

import { motion } from "motion/react";

// Beim Einhängen animieren
<motion.div
  initial={{ opacity: 0, y: 20 }}
  animate={{ opacity: 1, y: 0 }}
  transition={{ duration: 0.5 }}
>
  Hallo Welt
</motion.div>

// Beim Aushängen animieren (erfordert AnimatePresence)
import { AnimatePresence } from "motion/react";

<AnimatePresence>
  {isVisible && (
    <motion.div
      initial={{ opacity: 0 }}
      animate={{ opacity: 1 }}
      exit={{ opacity: 0 }}
    >
      Inhalt
    </motion.div>
  )}
</AnimatePresence>

Feder-Physik (Spring Physics)

<motion.div
  animate={{ x: 100 }}
  transition={{
    type: "spring",
    stiffness: 300,
    damping: 20,
    mass: 1,
  }}
/>

// Voreinstellungen
transition={{ type: "spring", bounce: 0.5 }}  // 0 = kein Federn, 1 = sehr federnd

Varianten (Orchestrierte Animationen)

const container = {
  hidden: { opacity: 0 },
  show: {
    opacity: 1,
    transition: {
      staggerChildren: 0.1,    // Verzögerung zwischen Kindern
      delayChildren: 0.3,       // Anfangsverzögerung
    },
  },
};

const item = {
  hidden: { opacity: 0, y: 20 },
  show: { opacity: 1, y: 0 },
};

<motion.ul variants={container} initial="hidden" animate="show">
  {items.map((i) => (
    <motion.li key={i} variants={item}>{i}</motion.li>
  ))}
</motion.ul>

Gesten

// Hover
<motion.button
  whileHover={{ scale: 1.05 }}
  whileTap={{ scale: 0.95 }}
>
  Klick mich
</motion.button>

// Drag (Ziehen)
<motion.div
  drag                          // Drag auf beiden Achsen aktivieren
  dragConstraints={{ left: -100, right: 100, top: -50, bottom: 50 }}
  dragElastic={0.2}
/>

Layout-Animationen

// Layout-Änderungen automatisch animieren
<motion.div layout>
  {isExpanded ? <ExpandedContent /> : <CollapsedContent />}
</motion.div>

// Gemeinsame Layout-Animation (zwischen Elementen morphen)
<motion.div layoutId="card">
  {/* Dieses Element morpht zwischen Positionen, wenn layoutId übereinstimmt */}
</motion.div>

Scroll-Animationen

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

function ParallaxSection() {
  const { scrollYProgress } = useScroll();
  const y = useTransform(scrollYProgress, [0, 1], [0, -200]);
  const opacity = useTransform(scrollYProgress, [0, 0.5, 1], [1, 1, 0]);

  return (
    <motion.div style={{ y, opacity }}>
      Parallax-Inhalt
    </motion.div>
  );
}

useAnimate (Imperativ)

import { useAnimate } from "motion/react";

function MyComponent() {
  const [scope, animate] = useAnimate();

  async function handleClick() {
    await animate(".box", { scale: 1.5 }, { duration: 0.3 });
    await animate(".box", { rotate: 360 }, { duration: 0.5 });
    await animate(".box", { scale: 1, rotate: 0 });
  }

  return (
    <div ref={scope}>
      <div className="box" onClick={handleClick}>Klick mich</div>
    </div>
  );
}

Keyframes

<motion.div
  animate={{
    x: [0, 100, 100, 0, 0],
    y: [0, 0, 100, 100, 0],
    rotate: [0, 90, 180, 270, 360],
  }}
  transition={{ duration: 2, repeat: Infinity }}
/>

Übergangstypen

// Spring (Standard für physikalische Werte)
transition={{ type: "spring", stiffness: 100, damping: 10 }}

// Tween (dauerbasiert)
transition={{ type: "tween", duration: 0.5, ease: "easeInOut" }}

// Easing-Optionen
ease: "linear" | "easeIn" | "easeOut" | "easeInOut"
ease: [0.42, 0, 0.58, 1]  // Benutzerdefinierte kubische Bézier-Kurve

// Wiederholung
transition={{ repeat: Infinity, repeatType: "reverse", duration: 1 }}

// Verzögerung
transition={{ delay: 0.5 }}

Häufige Muster

Seitenübergang

// In Layout-Komponente
<AnimatePresence mode="wait">
  <motion.div
    key={pathname}
    initial={{ opacity: 0, x: 20 }}
    animate={{ opacity: 1, x: 0 }}
    exit={{ opacity: 0, x: -20 }}
    transition={{ duration: 0.3 }}
  >
    {children}
  </motion.div>
</AnimatePresence>

Gestaffelte Liste

const container = {
  hidden: {},
  show: { transition: { staggerChildren: 0.08 } },
};
const item = {
  hidden: { opacity: 0, y: 15 },
  show: { opacity: 1, y: 0, transition: { type: "spring", bounce: 0.3 } },
};

Karte mit Vergrößerung bei Hover

<motion.div
  whileHover={{ scale: 1.03, boxShadow: "0 10px 30px rgba(0,0,0,0.15)" }}
  transition={{ type: "spring", stiffness: 400, damping: 25 }}
/>

Best Practices

  1. Varianten verwenden für orchestrierte Eltern-Kind-Animationen
  2. Feder-Physik für natürlich wirkende Bewegungen (lineares Easing vermeiden)
  3. layout-Prop für automatische Layout-Änderungsanimationen
  4. AnimatePresence für Exit-Animationen erforderlich
  5. layoutId für geteilte Elementübergänge zwischen Routen
  6. useScroll für scroll-gebundene Animationen (Parallax, Fortschrittsbalken)
  7. whileHover/whileTap für interaktives Feedback
  8. Staffelung der Kinder über die variant transition.staggerChildren
  9. Animationen subtil halten — 0,2-0,5s Dauer für UI-Interaktionen
  10. GPU-beschleunigt — Motion verwendet standardmäßig Transformationen

Wann Motion vs. GSAP verwenden

MotionGSAP
FrameworkReact-firstFramework-unabhängig
StilDeklarativ (JSX-Props)Imperativ (Funktionsaufrufe)
Layout-AnimationenIntegriert (magisch)Manuell
ScrolluseScroll-HookScrollTrigger-Plugin
GestenIntegriert (Drag, Hover, Tap)Draggable-Plugin
SVG-MorphingEingeschränktMorphSVGPlugin
Bundle-Größe~30KB~25KB Kern

Quelle

  • Repository: github.com/motiondivision/motion
  • Dokumentation: motion.dev
  • Beispiele: motion.dev/docs/react-quick-start

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

ever-just/agentskills

> Create animated logos, icons, and micro-interactions as lightweight Lottie JSON files. No After Effects needed — build animations entirely in code.

ever-just/agentskills

> A TypeScript library using generators to program animations with a real-time editor. Ideal for explainer videos, code walkthroughs, and educational content.

ever-just/agentskills

> Add animated subtitles and captions to Remotion videos from .SRT files. TikTok-style word-by-word highlights, karaoke effects, and more.

ever-just/agentskills

> Create videos programmatically using React components. The most mature framework for code-driven video production.

ever-just/agentskills

> Copy-paste video components for Remotion. Intros, text effects, transitions, and full scene templates. Like shadcn/ui but for video.

ever-just/agentskills

Extract actionable intelligence from video content across YouTube, Vimeo, and company websites. Video reveals what text sources cannot: facility scale, team composition, product demonstrations, signage, event attendance, and operational reality.

ever-just/agentskills

Optimize and embed an existing video as a fast, crisp, autoplaying hero/background/loop on a website. Use when adding or replacing a video on a marketing site and it is too heavy, will not autoplay (especially on mobile/Safari), shows a codec error, or looks soft — to transcode it to web-safe H.264 with the right pixel format, faststart, retina-aware sizing, and a poster frame, then embed and verify it actually plays. This is optimization + embedding of footage you already have, not creating/animating a video (for that use remotion/moviepy/motion-canvas). Use when the user says "add this video to the site", "the hero video is too big / won't play / isn't crisp", "replace the homepage video", or "make this loop on the landing page".

ever-just/agentskills

Full conversion audit for any homepage or landing page. Use when someone asks to "review my homepage," "audit my landing page," "why isn't my page converting," "check my website," or wants feedback on their marketing page. Requires URL or screenshot before proceeding.

ever-just/agentskills

Automatically fetch YouTube video transcripts, generate structured summaries, and send full transcripts to messaging platforms. Detects YouTube URLs and provides metadata, key insights, and downloadable transcripts.

Verwandte Skills