Langsung ke konten
Skillpedia
Antarmuka (UI/UX)280k Β· #213

motion-patterns

Fungsinya

Kode ini membantu membuat animasi yang halus dan siap pakai untuk website yang dibangun dengan React atau Next.js. Kode ini menyediakan pola untuk tombol, modal, toast, kemunculan daftar secara berurutan, dan transisi antarhalaman.

Kapan dipakai

  • βœ“Membuat animasi untuk tombol yang berubah ketika diklik.
  • βœ“Membuat daftar item muncul satu per satu secara berurutan.
  • βœ“Membuat transisi yang mulus saat berpindah halaman di website.

Link skill

https://github.com/affaan-m/ECC/blob/main/pi/core/skills/motion-patterns/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/affaan-m/ECC/blob/main/pi/core/skills/motion-patterns/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBuat animasi untuk tombol yang 'tertekan' saat diklik dan kembali normal saat dilepas.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Tool ini memakai 'pola' animasi yang sudah jadi, yang mengambil pengaturan kecepatan dan gerakan dari file terpisah. Dengan begitu, animasi tetap konsisten dan tidak memakai nilai tebakan secara langsung.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Motion Patterns

Copy-paste patterns for the most common UI animation needs. Every pattern here is built on motion-foundations tokens and springs. Do not define new duration or easing values here β€” import them.

When to Activate

  • Animating a button, card, modal, or toast notification
  • Building list entrances with stagger
  • Setting up page transitions in Next.js App Router
  • Adding entrance or exit animations to conditional content
  • Implementing scroll-reveal, scroll-linked progress, or sticky story sections
  • Building expanding cards, accordions, or shared-element transitions

Outputs

This skill produces:

  • Accessible, SSR-safe animation for all standard UI components
  • AnimatePresence-wrapped conditional renders with correct exit behavior
  • Page transition wrapper component for Next.js App Router
  • Scroll-reveal and scroll-linked patterns using useScroll + useTransform
  • Layout animation patterns (layout, layoutId) for expanding and crossfading elements

Principles

  • Every pattern imports from motion-foundations. No raw numbers.
  • Every conditional render is wrapped in AnimatePresence with a key.
  • Exit animations are always defined alongside enter animations β€” never as an afterthought.
  • layout is used only for small, isolated shifts. Large subtrees get explicit transforms.

Rules

  1. Always wrap conditional renders in AnimatePresence with a key on the direct child. Without a key, exit animations never fire.
  2. Always define exit when defining initial + animate. An animation without an exit is incomplete.
  3. Use mode="wait" on page transitions. Enter must not start until exit completes.
  4. Never use layout on subtrees with more than ~5 children or deeply nested DOM. Use explicit x/y transforms instead.
  5. Stagger interval must stay between 0.05s and 0.10s. Below feels mechanical; above feels sluggish.
  6. Modals must always include: focus trap, Escape-key close, scroll lock, role="dialog", aria-modal="true".
  7. Scroll reveals use viewport={{ once: true }}. Repeating on scroll-out is distracting, not informative.
  8. All token values are imported from motion-foundations. No inline numbers.

Decision Guidance

Choosing the right pattern

Situation Pattern
Element appears / disappears AnimatePresence
List of items loading in sequence Stagger variants
Navigating between routes Page transition wrapper
Element changes size in place layout prop
Same element moves across page contexts layoutId
Element enters when scrolled into view whileInView
Value tied to scroll position useScroll + useTransform

When to use mode="wait" vs mode="sync"

Mode Use when
wait Page transitions, content swaps (one at a time)
sync Stacked notifications, list items (overlap is fine)
popLayout Items removed from a reflow list

Core Concepts

AnimatePresence contract

Three things must always be true:

  1. AnimatePresence wraps the conditional
  2. The direct child has a key
  3. The child has an exit prop

Miss any one of these and the exit animation silently fails.

layout vs layoutId

  • layout β€” animates the element's own size/position change in place
  • layoutId β€” links two separate elements, crossfading between them across renders

Use layout="position" on text inside an expanding container to prevent text reflow from animating.

Code Examples

Button feedback

"use client"
import { motion } from "motion/react"
import { springs, motionTokens } from "@/lib/motion-tokens"

<motion.button
  whileHover={{ scale: motionTokens.scale.pop }}
  whileTap={{ scale: motionTokens.scale.press }}
  transition={springs.snappy}
/>

Stagger list

"use client"
import { motion } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"

const container = {
  hidden: {},
  visible: {
    transition: {
      staggerChildren: 0.08,   // within the 0.05–0.10 rule
      delayChildren: 0.1,
    },
  },
}

const item = {
  hidden:  { opacity: 0, y: motionTokens.distance.md },
  visible: { opacity: 1, y: 0, transition: springs.gentle },
}


…
Pertanyaan umum

Apa itu 'AnimatePresence'?

Itu adalah alat yang memastikan elemen yang menghilang juga dihilangkan dengan animasi, bukan langsung lenyap begitu saja.

Apa itu 'tokens' dan 'springs'?

Itu adalah pengaturan yang sudah ditentukan untuk tampilan (tokens) dan gerakan (springs), seperti kecepatan animasi dan 'kekenyalan' pantulan, agar semuanya tetap konsisten.

Kenapa tidak langsung menulis angka di dalam animasi?

Dengan memakai nilai yang sudah ditentukan (tokens), semua animasi di situs memiliki 'rasa' yang sama dan mudah diperbarui jika diperlukan.

Detail

Deskripsi asli dari pembuat

Production-ready animation patterns for React / Next.js β€” button, modal, toast, stagger, page transitions, exit animations, scroll, and layout β€” built on motion-foundations tokens and springs. Use when animating a specific UI element in React or Next.js β€” button, modal, toast, stagger, page transition, or scroll.

repo: affaan-m/ECC

Popularitas

Bintang GitHub
280k
Peringkat
#213
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa