# FLIP Layout Morph

> Shared-element layout transitions powered by GSAP Flip, with a premium grid-to-detail archive showcase plus reusable lightbox and filter APIs.

Canonical: https://gsapvault.com/effects/flip-layout-morph
Live demo: https://gsapvault.com/demos/flip-layout-morph/index.html

| Property | Value |
|----------|-------|
| Type | effect |
| Tier | paid |
| Price | £5 |
| Difficulty | intermediate |
| Plugins | Flip |
| Techniques | flip-layout, shared-element, lightbox, filter, stagger |
| Uses Lenis | No |

## Overview

A polished shared-element layout effect powered by GSAP's Flip plugin. The focused showcase turns an editorial project tile into a dominant dossier while the surrounding archive compresses into a quiet project rail, then returns the tile precisely to its original slot. Reusable lightbox and filter-and-rearrange APIs remain included for production builds.

## Features

- Grid-to-detail shared-element morph from the tile's exact geometry
- Synchronized surrounding-grid reflow and opacity response
- Layered project metadata and display typography reveal
- Smooth position, scale, and border-radius interpolation with Flip
- Precise reverse transition back to the original grid slot
- Reusable modal lightbox morph API with focus restoration
- Reusable category filter API with staggered enter and exit states
- Configurable duration, easing, and stagger through data attributes
- Keyboard, Escape, focus-trap, and reduced-motion support

## Use Cases

- Editorial portfolios with immersive project dossiers
- Agency case-study grids with shared-element continuity
- Product catalogs with focused quick-view compositions
- Image galleries with accessible modal previews
- Filterable archives with animated layout changes

## Vibe-Code Ready Setup

This effect includes `START-HERE-AI.md`, a product-specific copy-paste setup prompt for Cursor, Claude Code, ChatGPT, GitHub Copilot, Windsurf, and other coding assistants. It tells the assistant to inspect the existing stack, integrate the supplied files, preserve the design, scope selectors, retain accessibility and responsive behaviour, add framework-appropriate GSAP cleanup, and report what it tested.

[How AI-assisted setup works](https://gsapvault.com/vibe-coding)

## How It Works

The Flip plugin captures every card's current state with Flip.getState(), then the selected card is reparented into the detail composition while the archive switches to its compact layout. Flip.from() interpolates the selected colour field and all surrounding card geometry, while a GSAP timeline layers in metadata and typography with restrained power easing.

On close, the current composition is captured before the card is returned to its matching data-flip-slot and the archive layout is restored, producing a precise no-jump reverse. Reduced-motion users receive the same DOM and focus state changes instantly. The included lightbox and filter initializers use the same capture-change-animate pattern and share context-based cleanup.

## Integration Preview

How this effect integrates into a page. The full documentation (examples, events, programmatic API, customization guide) ships with the download.

### Quick Start

**1. Add to your HTML `<head>`:**

```html
<link rel="stylesheet" href="flip-layout-morph/style.css">
```

**2. Add before the closing `</body>` tag:**

```html
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/Flip.min.js"></script>
<script src="flip-layout-morph/script.js"></script>
```

**3. Add to your `<body>`:**

```html
<div class="flip-morph-container" data-flip-morph data-flip-duration="0.8" data-flip-ease="power3.inOut">
  <div class="flip-grid">
    <div class="flip-grid-slot" data-flip-slot="project-a">
      <button class="flip-card" type="button" data-flip-id="project-a"
        data-detail-title="Project A"
        data-detail-kicker="Identity / 2026"
        data-detail-description="A concise project description."
        aria-haspopup="dialog" aria-expanded="false">
        <span class="flip-card-thumb"></span>
        <span class="flip-card-info"><strong>Project A</strong></span>
      </button>
    </div>
  </div>

  <div class="flip-detail" role="dialog" aria-modal="true" aria-label="Project detail" aria-hidden="true">
    <div class="flip-detail-media"></div>
    <div class="flip-detail-content">
      <p data-detail-kicker data-detail-reveal>Identity / 2026</p>
      <h2 data-detail-title data-detail-reveal>Project A</h2>
      <p data-detail-description data-detail-reveal>A concise project description.</p>
    </div>
    <button class="flip-detail-close" type="button" aria-label="Close project detail">Close</button>
  </div>
</div>
```

The `.flip-detail-media` wrapper and `data-detail-*` content hooks are optional. Without them, the card is appended directly to `.flip-detail`, preserving the minimal API.

### Options

| Attribute | Element | Default | Description |
|---|---|---:|---|
| `data-flip-morph` | Container | — | Initializes grid-to-detail behavior |
| `data-flip-lightbox` | Container | — | Initializes thumbnail-to-lightbox behavior |
| `data-flip-filter` | Container | — | Initializes filter and rearrange behavior |
| `data-flip-duration` | Container | `0.7` morph/filter, `0.6` lightbox | Transition duration in seconds |
| `data-flip-ease` | Container | `power3.inOut` morph/lightbox | GSAP ease used for FLIP geometry |
| `data-flip-stagger` | Filter container | `0.04` | Delay between rearranging items |
| `data-flip-id` | Morph card | — | Unique identifier for return placement |
| `data-flip-slot` | Grid slot | — | Identifier matching `data-flip-id` |
| `data-detail-title` | Morph card | — | Optional detail title copied into `[data-detail-title]` |
| `data-detail-kicker` | Morph card | — | Optional detail metadata copied into `[data-detail-kicker]` |
| `data-detail-description` | Morph card | — | Optional copy inserted into `[data-detail-description]` |
| `data-detail-index` | Morph card | — | Optional index copied into `[data-detail-index]` |
| `data-caption` / `data-meta` | Lightbox thumb | — | Caption content for the modal lightbox |
| `data-filter` | Filter button | — | Category to show; use `all` for every item |
| `data-flip-category` | Filter item | — | Category matched by a filter button |

### Accessibility

- Use native `<button>` elements for cards, thumbnails, close controls, and filters. Legacy focusable elements with `role="button"` are still supported.
- Enter, Space, pointer activation, and Escape are supported. Focus moves to the close control and returns to the triggering card.
- Open dialogs trap Tab focus. Background archive cards are removed from the tab order while a detail is open.
- `prefers-reduced-motion: reduce` swaps states instantly while preserving all content and focus behavior.
- Keep descriptive `aria-label`, `aria-haspopup`, `aria-expanded`, `aria-hidden`, and dialog labels in your markup.

### Browser Support

Modern browsers with ES6 support.

### Dependencies

- [GSAP 3.14+](https://gsap.com/) core
- [GSAP Flip](https://gsap.com/docs/v3/Plugins/Flip/)

## What You Get

- `index.html`: working demo page
- `assets/script.js`: commented, readable source
- `assets/style.css`: effect styles
- `README.md`: full documentation with examples and framework integration notes
- `START-HERE-AI.md`: product-specific copy-paste prompt for AI-assisted setup
- `LICENSE.txt`: standard license terms
- Lifetime updates: re-download anytime from your library

## Get the Code

This is a premium effect. The standard license costs £5 one-time and covers unlimited personal and commercial projects with no attribution required. The only restrictions: no redistribution of the code itself and no competing effect libraries.

- [Buy FLIP Layout Morph](https://gsapvault.com/effects/flip-layout-morph)
- [Effects & Templates Vault (£39 one-time, best value): every current and future effect and template](https://gsapvault.com/effects)

## Judge the Code Quality First

These related effects are free with complete source published, written to the same production standard (cleanup functions, reduced-motion support, framework-agnostic):

- [Hover Underline](https://gsapvault.com/effects/hover-underline.md): Three material link underlines—an exit-through line, marker sweep, and hand-drawn wave—with coordinated type and active-index responses.
- [Image Clip Reveal](https://gsapvault.com/effects/image-clip-reveal.md): A cinematic image reveal where a directional polygon aperture opens as the photograph settles from a restrained Ken Burns scale and its editorial caption lands.
- [3D Card Flip Gallery](https://gsapvault.com/effects/3d-card-flip.md): Tactile 3D cards with deep perspective, reactive edge-light, shadow inversion, hover/focus parity, and tap auto-close.

---

From [GSAP Vault](https://gsapvault.com): production-ready GSAP animation effects. Full catalog for agents: https://gsapvault.com/llms-full.txt
