All components

MotionList

A list from data that animates only what changed.

WebReact NativeLists

Try it

Preparing the example…

Shortest usage

Todos.jsx
<MotionList as="ul" items={todos} renderItem={(todo) => <TodoRow todo={todo} />} />;

What it handles for you

  • New items enter with a bounded stagger while untouched items stay still.
  • Removed items leave the flow and animate out where they were while the rest slide into the gap.
  • Reordered items glide to their new positions.
  • Moves interrupted by another change keep their velocity.
  • present={false} animates every item out, and playKey replays the entrance.

Use it for

  • A todo list.
  • Filtered search results.
  • A shopping cart.

Props

PropTypeDefaultDescription
itemsreadonly T[]—requiredYour data array.
getKey(item) => string | numberitem.idReturns a unique, stable key for an item. Defaults to item.id, or the item itself for strings and numbers.
renderItem(item, index) => ReactNodeitem.labelDraws an item.
aselement'div'The element to render.
itemAselement'li' | 'div'The element for each item.
itemClassNamestringClass for each item element; itemStyle sets its inline style.
effect'rise' | 'fade' | 'scale' | 'slide''rise'How items enter and leave.
distancenumber16Travel of rise and slide in pixels.
staggernumber40Milliseconds between entering items.
order'forward' | 'reverse''forward'Direction of the stagger.
presentbooleantruefalse animates every item out while keeping the layout; true brings them back.
initialbooleantruePlay the entrance when the list mounts.
playKeystring | numberChanging it replays the entrance.
transitionTransitionspringTransition for entering and leaving items.
layoutTransitionTransitionspringTransition for items gliding to new positions.

Other props go to the rendered element, so className, style and event handlers work as usual.

Web and React Native

Each item gets a wrapper element (li inside ul or ol, otherwise div; itemAs changes it) styled with itemClassName.

Keys must be unique. Wrap the list in MotionHeight to animate its total height as well.

Used in these examples

Search

Type to search the documentation.