Communitygithub.com

Motion (Framer Motion) — Bibliothèque d'animations React

Animations déclaratives pour React. Ressorts, gestes, animations de mise en page et transitions de page. Accéléré par GPU, prêt pour la production.

Qu'est-ce que Motion (Framer Motion) — Bibliothèque d'animations React ?

Motion (anciennement Framer Motion) est une bibliothèque d'animations UI déclarative et puissante pour React, conçue pour créer des interfaces utilisateur fluides et expressives avec des animations naturelles. Elle exploite les ressorts physiques, les gestes (hover, tap, drag), les animations de mise en page automatiques et les transitions de page. Son API est basée sur le composant `motion` et les props déclaratives comme `animate`, `initial`, `exit` et `variants`, facilitant l'orchestration d'animations complexes entre parents et enfants. La bibliothèque est optimisée pour le rendu GPU (via les transformations CSS) et est idéale pour les applications React modernes. Motion est supporté par une grande communauté (26K+ étoiles GitHub) et est documenté sur motion.dev.

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

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Motion (Framer Motion) — Bibliothèque d'animations UI pour React

Animations déclaratives pour React. Ressorts, gestes, animations de mise en page et transitions de page. Accéléré par GPU, prêt pour la production.

Aperçu

  • Dépôt : github.com/motiondivision/motion (26K+ étoiles)
  • Langage : TypeScript / React
  • Licence : MIT
  • Installation : npm install motion
  • Documentation : motion.dev
  • Remarque : Framer Motion a été renommé Motion. Importer depuis motion/react.

API principale

Animation de base

import { motion } from "motion/react";

// Animer au montage
<motion.div
  initial={{ opacity: 0, y: 20 }}
  animate={{ opacity: 1, y: 0 }}
  transition={{ duration: 0.5 }}
>
  Bonjour le monde
</motion.div>

// Animer à la sortie (nécessite AnimatePresence)
import { AnimatePresence } from "motion/react";

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

Physique de ressort (Spring)

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

// Presets
transition={{ type: "spring", bounce: 0.5 }}  // 0 = pas de rebond, 1 = très rebondissant

Variantes (Animations orchestrées)

const container = {
  hidden: { opacity: 0 },
  show: {
    opacity: 1,
    transition: {
      staggerChildren: 0.1,    // Délai entre les enfants
      delayChildren: 0.3,       // Délai initial
    },
  },
};

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>

Gestes

// Hover
<motion.button
  whileHover={{ scale: 1.05 }}
  whileTap={{ scale: 0.95 }}
>
  Cliquez-moi
</motion.button>

// Drag
<motion.div
  drag                          // Active le glissement sur les deux axes
  dragConstraints={{ left: -100, right: 100, top: -50, bottom: 50 }}
  dragElastic={0.2}
/>

Animations de mise en page

// Animer automatiquement les changements de mise en page
<motion.div layout>
  {isExpanded ? <ContenuEtendu /> : <ContenuReduit />}
</motion.div>

// Animation de mise en page partagée (morphing entre éléments)
<motion.div layoutId="carte">
  {/* Cet élément se transforme entre les positions lorsque layoutId correspond */}
</motion.div>

Animations liées au défilement

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

function SectionParallaxe() {
  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 }}>
      Contenu parallaxe
    </motion.div>
  );
}

useAnimate (Impératif)

import { useAnimate } from "motion/react";

function MonComposant() {
  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}>Cliquez-moi</div>
    </div>
  );
}

Images clés (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 }}
/>

Types de transition

// Spring (par défaut pour les valeurs physiques)
transition={{ type: "spring", stiffness: 100, damping: 10 }}

// Tween (basé sur la durée)
transition={{ type: "tween", duration: 0.5, ease: "easeInOut" }}

// Options d'easing
ease: "linear" | "easeIn" | "easeOut" | "easeInOut"
ease: [0.42, 0, 0.58, 1]  // Bézier cubique personnalisé

// Répétition
transition={{ repeat: Infinity, repeatType: "reverse", duration: 1 }}

// Délai
transition={{ delay: 0.5 }}

Modèles courants

Transition de page

// Dans le composant de mise en page
<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>

Liste échelonnée

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 } },
};

Carte avec zoom au survol

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

Bonnes pratiques

  1. Utilisez des variantes pour les animations orchestrées parent/enfant
  2. La physique de ressort pour des mouvements naturels (évitez l'easing linéaire)
  3. La propriété layout pour les animations automatiques de changement de mise en page
  4. AnimatePresence requis pour les animations de sortie
  5. layoutId pour les transitions d'éléments partagés entre les routes
  6. useScroll pour les animations liées au défilement (parallaxe, barres de progression)
  7. whileHover/whileTap pour un retour interactif
  8. Échelonnement des enfants via la variante transition.staggerChildren
  9. Gardez les animations subtiles — durée de 0,2 à 0,5 s pour les interactions UI
  10. Accéléré par GPU — Motion utilise les transformations par défaut

Quand utiliser Motion vs GSAP

MotionGSAP
FrameworkReact d'abordFramework-agnostique
StyleDéclaratif (props JSX)Impératif (appels de fonctions)
Animations layoutIntégré (magique)Manuel
DéfilementHook useScrollPlugin ScrollTrigger
GestesIntégré (drag, hover, tap)Plugin Draggable
Morphing SVGLimitéPlugin MorphSVGPlugin
Taille du bundle~30KB~25KB noyau

Source

  • Dépôt : github.com/motiondivision/motion
  • Documentation : motion.dev
  • Exemples : 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.

Skills associés