Tillitsdone
down Scroll to discover

Animating Lists in React with Framer Motion

Learn how to create fluid, engaging animations for dynamic lists and arrays in React using Framer Motion.

Master list transitions, reordering, and staggered animations with practical examples.
thumbnail

A flowing abstract composition with interconnected geometric shapes floating in space featuring bright cerulean blue and seafoam green gradients viewed from a slightly elevated angle high-quality ultra-realistic cinematic 8K UHD high resolution sharp and detail

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.

Abstract fluid motion of bright orange and golden waves flowing through a minimalist architectural space captured from a front perspective high-quality ultra-realistic cinematic 8K UHD high resolution sharp and detail

Getting Started with Framer Motion

Before diving into list animations, let’s set up our project. First, install Framer Motion:

Terminal window
npm install framer-motion

The 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

Modern minimalist structure with cascading layers in warm walnut browns and iron greys photographed from a low angle perspective high-quality ultra-realistic cinematic 8K UHD high resolution sharp and detail

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

  1. Always use unique, stable keys for list items
  2. Keep animations subtle and purposeful
  3. Consider reduced motion preferences
  4. Test animations at different screen sizes
  5. Use spring animations for more natural movement

Ethereal landscape with floating geometric patterns in October mist and sand colors with black accents viewed from a bird's eye perspective high-quality ultra-realistic cinematic 8K UHD high resolution sharp and detail

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.

icons/logo-tid.svg

Talk with CEO

Ready to bring your web/app to life or boost your team with expert Thai developers?
Contact us today to discuss your needs, and let’s create tailored solutions to achieve your goals. We’re here to help at every step!
🖐️ Contact us
Let's keep in Touch
Thank you for your interest in Tillitsdone! Whether you have a question about our services, want to discuss a potential project, or simply want to say hello, we're here and ready to assist you.
We'll be right here with you every step of the way.
Contact Information
rick@tillitsdone.com+66824564755
Find All the Ways to Get in Touch with Tillitsdone - We're Just a Click, Call, or Message Away. We'll Be Right Here, Ready to Respond and Start a Conversation About Your Needs.
Address
9 Phahonyothin Rd, Khlong Nueng, Khlong Luang District, Pathum Thani, Bangkok Thailand
Visit Tillitsdone at Our Physical Location - We'd Love to Welcome You to Our Creative Space. We'll Be Right Here, Ready to Show You Around and Discuss Your Ideas in Person.
Social media
Connect with Tillitsdone on Various Social Platforms - Stay Updated and Engage with Our Latest Projects and Insights. We'll Be Right Here, Sharing Our Journey and Ready to Interact with You.
We anticipate your communication and look forward to discussing how we can contribute to your business's success.
We'll be here, prepared to commence this promising collaboration.
Frequently Asked Questions
Explore frequently asked questions about our products and services.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.