Motion+

iOS App Folder

An iOS-style app folder that expands to reveal apps inside, using Motion for React's layout animations and AnimatePresence.

Time
5 min
Difficulty
Advanced
Access
Motion+
>Live exampleOpen in new tab

Introduction

The iOS App Folder example recreates the familiar iOS folder interaction where tapping a folder expands it to reveal all the apps inside. This example showcases several advanced layout animation techniques from Motion for React, creating a polished, native-feeling experience.

We'll use AnimatePresence with mode="popLayout" to smoothly transition between the closed and open folder states, the layoutId prop to create seamless shared element transitions between the mini-grid and expanded view, MotionConfig to set a consistent transition for all layout animations, and traditional animation props like initial, animate, and exit for items that don't have layoutId.

The example also demonstrates staggered animations where different items animate at different times based on their position, and position measurement techniques using useLayoutEffect to calculate where items should animate from.

The clever technique here is combining two animation approaches. Some items (those with layoutId) appear in both the mini-grid and expanded view, smoothly morphing between positions. Other items animate in from the center of the mini-grid using scale and position transforms, creating the illusion they're emerging from the folder.