Report a problem or share feedback← Catalog
Shared layout animation
curatedfreemotion/shared-layout-animation
An example of a shared layout animation, where two elements are animated from one to the other, using Motion for React's simple layoutId prop.
$
pnpm add motion # then adapt the free source from https://motion.dev/examples/react-shared-layout-animationnpm deps: motion
Our notes
Shared-element layoutId: a tab underline / pill that glides between items. The free, hand-rolled way to animate tabs, nav highlights and segmented controls — about 10 lines with `layoutId`. Free example (motion is MIT); copy and adapt the source from the example page.
- Source
- Motion (motion.dev)
- Kind
- transition
- Categories
- transition
- Use as
- recipe — technique you apply to your own markup
- Applies to
- tabsnavigationbutton
- Motion
- on state · subtle · motion · low cost
- Tags
- motion, AnimatePresence, animate, layoutId
- Licence
- motion / motion/react / motion-v are MIT. Motion+ (premium components, example source, AI Kit pro tools) is paid — one-time Personal licence or per-seat Business.
- Live demo
- motion.dev
- Docs
- motion.dev
Similar
Compare all 4 →- Clerk: User Buttonmotion/clerk-user-buttonA custom Clerk user button built with Motion. The closed avatar expands into an account menu, using Motion's resize() util to animate the container to the menu's measured height.
- Expanding Icon Tabsmicrokit/expanding-icon-tabsIcon toolbar whose chosen item widens to show its label while siblings slide over; ←/→ move focus, Escape and outside-click collapse it, role=toolbar, motion-reduce handled. Good for compact app toolbars and view switchers. Hard-coded items and light-dark() hex colours — rebuild with your icons and tokens.
- Plus to menu morphtransitions/plus-menu-morphA small circular trigger (a "+" FAB, a compose button, an add-action affordance) that **morphs into the menu / panel it opens** instead of popping a separate surface next to it. The button's box grows in width / height and relaxes its corner radius into a rounded panel while the plus icon cross-fades + rotates out and the menu content slides in.