- Services
- Case Studies
- Technologies
- NextJs development
- Flutter development
- NodeJs development
- ReactJs development
- About
- Contact
- Tools
- Blogs
- FAQ
Animating Lists in React with Framer Motion
Master list transitions, reordering, and staggered animations with practical examples.

Animating Lists and Arrays in React Using Framer Motion
If you’ve ever wanted to make your React applications more engaging, adding smooth animations to your lists and arrays is a fantastic way to enhance user experience. Today, we’ll explore how to bring life to your dynamic content using Framer Motion, the powerful animation library for React.
Why Animate Lists?
Think about those moments when items in your list update, reorder, or get removed. Without animations, these changes happen instantly, potentially confusing users about what just occurred. Adding thoughtful animations helps users track these changes, making your application not just more beautiful, but more usable.

Getting Started with Framer Motion
Before diving into list animations, let’s set up our project. First, install Framer Motion:
npm install framer-motionThe magic happens with Framer Motion’s AnimatePresence component and the motion elements. These tools handle the animation of elements entering, moving, and leaving your list.
Basic List Animation
Let’s start with a simple example. Here’s how to animate items as they appear and disappear:
import { motion, AnimatePresence } from 'framer-motion';
function AnimatedList({ items }) { return ( <ul> <AnimatePresence> {items.map(item => ( <motion.li key={item.id} initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -20 }} transition={{ duration: 0.5 }} > {item.text} </motion.li> ))} </AnimatePresence> </ul> );}Advanced Techniques
Staggered Animations

Want to make your list animations more dynamic? Staggered animations add a professional touch:
function StaggeredList({ items }) { return ( <ul> <AnimatePresence> {items.map((item, index) => ( <motion.li key={item.id} initial={{ opacity: 0, x: -50 }} animate={{ opacity: 1, x: 0 }} exit={{ opacity: 0, x: 50 }} transition={{ duration: 0.5, delay: index * 0.1, ease: "easeOut" }} > {item.text} </motion.li> ))} </AnimatePresence> </ul> );}Reordering Animations
The real power of Framer Motion shines when handling list reordering. Here’s how to create smooth transitions when items change position:
function ReorderableList({ items }) { return ( <ul> <AnimatePresence> {items.map((item) => ( <motion.li key={item.id} layout initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ type: "spring", stiffness: 300, damping: 30 }} > {item.text} </motion.li> ))} </AnimatePresence> </ul> );}Best Practices and Tips
- Always use unique, stable keys for list items
- Keep animations subtle and purposeful
- Consider reduced motion preferences
- Test animations at different screen sizes
- Use spring animations for more natural movement

Conclusion
Framer Motion transforms ordinary React lists into engaging, interactive elements that enhance user experience. Whether you’re building a simple todo list or a complex data visualization, these animation techniques will help your content feel more polished and professional.
Remember, the key to great animations is finding the right balance between aesthetics and functionality. Start simple, experiment with different effects, and always keep your users’ experience in mind.
สร้างเว็บไซต์ 1 เว็บ ต้องใช้งบเท่าไหร่? เจาะลึกทุกองค์ประกอบ website development cost อยากสร้างเว็บไซต์แต่ไม่มั่นใจในเรื่องของงบประมาณ อ่านสรุปเจาะลึกตั้งแต่ดีไซน์, ฟังก์ชัน และการดูแล พร้อมตัวอย่างงบจริงจาก Till it’s done ที่แผนชัด งบไม่บานปลายแน่นอน
Next.js สอน 14 ขั้นตอนเบื้องต้น: สร้างโปรเจกต์แรกใน 30 นาที เริ่มต้นกับ Next.js ใน 14 ขั้นตอนเพียงแค่ 30 นาที พร้อม SSR/SSG และ API Routes ด้วยตัวอย่างโค้ดง่าย ๆ อ่านต่อเพื่อสร้างโปรเจ็กต์แรกได้ทันทีที่นี่
วิธีสมัคร Apple Developer Account เพื่อนำแอปขึ้น App Store ทีละขั้นตอน อยากปล่อยแอปบน App Store ระดับโลก มาอ่านคู่มือสมัคร Apple Developer Account พร้อมเคล็ดลับ TestFlight และวิธีอัปโหลดที่ง่ายในบทความเดียวนี้ได้เลย
TypeScript Interface คืออะไร? อธิบายพร้อมวิธีใช้และข้อแตกต่างจาก Type เรียนรู้วิธีใช้ TypeScript Interface เพื่อสร้างโครงสร้างข้อมูลที่ปลอดภัยและเข้าใจง่าย พร้อมเปรียบเทียบข้อดีข้อแตกต่างกับ Type ที่คุณต้องรู้ ถูกรวมเอาไว้ในบทความนี้แล้ว
Material-UI (MUI) คืออะไร อยากสร้าง UI สวยงามและเป็นมืออาชีพในเวลาอันรวดเร็วใช่ไหม มาทำความรู้จักกับ Material-UI (MUI) ที่ช่วยให้คุณพัฒนาแอปพลิเคชันบน React ได้ง่ายและดูดีในทุกอุปกรณ์
เปรียบเทียบ 3 วิธีติดตั้ง install node js บน Ubuntu: NVM vs NodeSource vs Official Repo แบบไหนดีที่สุด? เรียนรู้วิธีติดตั้ง Node.js บน Ubuntu ด้วย NVM, NodeSource หรือ Official Repo เลือกวิธีที่เหมาะกับความต้องการของคุณ พร้อมเปรียบเทียบ เพื่อการพัฒนาที่มีประสิทธิภาพ! พูดคุยกับซีอีโอ
We'll be right here with you every step of the way.
We'll be here, prepared to commence this promising collaboration.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.