Communitygithub.com

Motion (Framer Motion) — Librería de Animaciones UI para React

Animaciones declarativas para React. Muelles, gestos, animaciones de diseño y transiciones de página. Acelerado por GPU, listo para producción.

¿Qué es Motion (Framer Motion) — Librería de Animaciones UI para React?

Motion (antes Framer Motion) es una biblioteca de animaciones declarativas para React, diseñada para desarrolladores que buscan crear interfaces de usuario fluidas e interactivas con facilidad. Ofrece soporte para animaciones basadas en muelles (springs), gestos (hover, tap, drag), animaciones de diseño (layout) y transiciones de página, todo acelerado por GPU para un rendimiento óptimo en producción. La API se integra de forma natural con React, utilizando componentes como `motion.div` y hooks como `useScroll`, `useTransform` y `useAnimate`. Es ideal para desarrolladores de React que necesitan animaciones complejas con mínimos esfuerzos, ofreciendo variantes para orquestación, animaciones de salida con `AnimatePresence`, y transiciones entre elementos compartidos con `layoutId`. Compatible con TypeScript y con licencia MIT, su instalación es sencilla mediante `npm install motion`. La biblioteca es mantenida por Motion Division, cuenta con más de 26,000 estrellas en GitHub y tiene una documentación completa en motion.dev.

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

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

¿Qué hace Motion (Framer Motion) — Librería de Animaciones UI para React?

Animaciones declarativas para React. Muelles, gestos, animaciones de diseño y transiciones de página. Acelerado por GPU, listo para producción.

Descripción General

  • Repositorio: github.com/motiondivision/motion (más de 26K estrellas)
  • Lenguaje: TypeScript / React
  • Licencia: MIT
  • Instalación: npm install motion
  • Documentación: motion.dev
  • Nota: Framer Motion fue renombrado a Motion. Importa desde motion/react.

API Principal

Animación Básica

import { motion } from "motion/react";

// Animar al montar
<motion.div
  initial={{ opacity: 0, y: 20 }}
  animate={{ opacity: 1, y: 0 }}
  transition={{ duration: 0.5 }}
>
  Hola Mundo
</motion.div>

// Animar al salir (requiere AnimatePresence)
import { AnimatePresence } from "motion/react";

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

Física de Muelle (Spring)

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

// Preajustes
transition={{ type: "spring", bounce: 0.5 }}  // 0 = sin rebote, 1 = muy rebotante

Variantes (Animaciones Orquestadas)

const container = {
  hidden: { opacity: 0 },
  show: {
    opacity: 1,
    transition: {
      staggerChildren: 0.1,    // Retardo entre hijos
      delayChildren: 0.3,       // Retardo inicial
    },
  },
};

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>

Gestos

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

// Arrastrar
<motion.div
  drag                          // Habilitar arrastre en ambos ejes
  dragConstraints={{ left: -100, right: 100, top: -50, bottom: 50 }}
  dragElastic={0.2}
/>

Animaciones de Diseño (Layout)

// Animar automáticamente cambios de diseño
<motion.div layout>
  {isExpanded ? <ContenidoExpandido /> : <ContenidoColapsado />}
</motion.div>

// Animación de diseño compartida (morfar entre elementos)
<motion.div layoutId="card">
  {/* Este elemento morfa entre posiciones cuando layoutId coincide */}
</motion.div>

Animaciones de Desplazamiento (Scroll)

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

function SeccionParallax() {
  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 }}>
      Contenido parallax
    </motion.div>
  );
}

useAnimate (Imperativo)

import { useAnimate } from "motion/react";

function MiComponente() {
  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}>Haz clic</div>
    </div>
  );
}

Fotogramas Clave (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 }}
/>

Tipos de Transición

// Spring (predeterminado para valores físicos)
transition={{ type: "spring", stiffness: 100, damping: 10 }}

// Tween (basado en duración)
transition={{ type: "tween", duration: 0.5, ease: "easeInOut" }}

// Opciones de easing
ease: "linear" | "easeIn" | "easeOut" | "easeInOut"
ease: [0.42, 0, 0.58, 1]  // Cubic bezier personalizado

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

// Retardo
transition={{ delay: 0.5 }}

Patrones Comunes

Transición de Página

// En el componente de layout
<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>

Lista Escalonada

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

Tarjeta con Escala al Pasar el Ratón

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

Mejores Prácticas

  1. Usa variantes para animaciones orquestadas padre/hijo
  2. Física de muelle para movimiento natural (evita easing lineal)
  3. Propiedad layout para animaciones automáticas de cambio de diseño
  4. AnimatePresence requerido para animaciones de salida
  5. layoutId para transiciones de elementos compartidos entre rutas
  6. useScroll para animaciones vinculadas al desplazamiento (parallax, barras de progreso)
  7. whileHover/whileTap para retroalimentación interactiva
  8. Escalonar hijos mediante transition.staggerChildren en variantes
  9. Mantén las animaciones sutiles — duración de 0.2-0.5s para interacciones UI
  10. Acelerado por GPU — Motion usa transformaciones por defecto

Cuándo Usar Motion vs GSAP

MotionGSAP
FrameworkReact-firstAgnóstico de framework
EstiloDeclarativo (props JSX)Imperativo (llamadas a funciones)
Animaciones de diseñoIntegradas (mágicas)Manual
DesplazamientoHook useScrollPlugin ScrollTrigger
GestosIntegrados (arrastrar, hover, tap)Plugin Draggable
Morphing SVGLimitadoPlugin MorphSVG
Tamaño del bundle~30KB~25KB núcleo

Fuente

  • Repositorio: github.com/motiondivision/motion
  • Documentación: motion.dev
  • Ejemplos: 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 relacionados