Skip to main content

React animation example

React Page Transition: Shared Element (Hero) Animation

A shared element transition keeps the thing you tapped on screen while the page changes around it, which tells people where they came from. Here a grid of cards opens into a detail page: the card's image becomes the header, the rest of the page fades in after it, and tapping back reverses the whole move.

  • 4.6 KB file
  • 5 live inputs
  • React runtime
Live, try it

How this shared element transition works

  • The opened card's rectangle is interpolated from its grid slot to the full stage with an under-damped spring.
  • Detail content waits until the spring is 60% of the way there, so it never overlaps the moving card.
  • Events "open" and "close" fire with each transition, ready for your router or analytics.

Add it to your React app

Install exodeui, download the file below, and paste this. The code updates as you customize. Other runtimes are in the other tabs.

import { ExodeUICanvas } from 'exodeui';

// react-page-transition.bexode goes in /public (download it below)
export function ReactPageTransition() {
  return (
    <ExodeUICanvas
      src="/react-page-transition.bexode"
      fit="Layout"
      autoPlay
      interactive
      onTrigger={(name) => {
        // fires: 'open', 'close'
      }}
      style={{ width: '100%', height: 540 }}
    />
  );
}

Inputs

InputTypeDefaultRange
stiffnessNumber17060 – 400
dampingNumber186 – 40
accentText#f97316hex colour
inkText#fafafahex colour
bgText#0c0a09hex colour

Events: openclose

More React animations

The same idea in other frameworks: Flutter hero product transition · JavaScript curtain wipe transition · Vue slide and fade route transition