Skip to content
IndexRequest a UIAboutContact

Shared Element Transition

A thumbnail grows into a detail view, so the user sees it is the same object.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Create a 300x200px container with a 72x72px thumbnail button (neutral gradient, rounded 12px) at the top left. Clicking it opens a detail state in which the same element becomes a full-container panel (inset 8px) with a title, a paragraph and a Close button. Implement it with FLIP: measure the element's rectangle before changing its layout class, measure again after, then animate with element.animate from transform translate(dx,dy) scale(sx,sy) with transform-origin top left to none over 380ms cubic-bezier(.2,.7,.2,1). Fade the detail text in over 200ms after a 180ms delay. Closing reverses the animation. Move focus to the Close button on open and back to the thumbnail on close, handle Escape, and set aria-expanded on the thumbnail. Under prefers-reduced-motion skip the transform animation and use a 100ms fade.

About this pattern

Definition

An element that exists in two layouts moves and resizes between them, instead of one view disappearing and another appearing. The FLIP technique (First, Last, Invert, Play) measures both layouts and animates the difference.

Purpose & UX principles

  • Keeps people oriented: they see where the detail came from and where it returns to.
  • Animating transform is cheap, so it stays smooth even on modest devices.
  • Detail content fades in after the shape settles, so text is never stretched.

Interaction states

  • Thumbnail, expanding, open, collapsing; focus moves to the close button when open and back to the thumbnail after.

Motion specification

  • Shape: translate and scale from the thumbnail rectangle to the full rectangle, 380ms cubic-bezier(.2,.7,.2,1) using the Web Animations API.
  • Detail text: opacity 0 to 1 over 200ms starting at 180ms.
  • Reduced motion: the view switches instantly with a 100ms fade.

Responsive behaviour

  • Both positions are measured at the moment of the click, so the animation adapts to any container size.
  • The close control is a real button and Escape also closes.

Code

HTML
<div class="box" id="box">
  <div class="el" id="el" role="button" tabindex="0" aria-expanded="false" aria-label="Open Aurora details"><div class="in" id="in" hidden><b>Aurora</b><p>A soft gradient study used for backgrounds. The panel grew from the thumbnail you pressed.</p><button class="x" id="x" type="button">Close</button></div></div>
</div>

Related patterns

Modal Dialog

↗
Modal DialogOverlays & Dialogs

Expandable Card

↗
Expandable CardCards & Containers

Spring Follow

↗
Spring FollowMotion & Transitions