# Elastic Stack Cards

> Stacked cards that spring open into a fan. Three fan shapes, opened by hover, focus, tap or an external button, with click-to-front card selection.

Canonical: https://gsapvault.com/effects/elastic-stack-cards
Live demo: https://gsapvault.com/demos/elastic-stack-cards/index.html

| Property | Value |
|----------|-------|
| Type | effect |
| Tier | paid |
| Price | £5 |
| Difficulty | intermediate |
| Plugins | ScrollTrigger |
| Techniques | hover-effect, stagger, scroll-reveal, scrub, 3d-transforms |
| Uses Lenis | Yes |

## Overview

A capability deck that rests as a tight pile and springs into a full-width fan on hover, focus or tap. Three fan shapes ship with it — an even spread, a curved arc, and a diagonal cascade — switchable at runtime from any button on the page, and the deck can be held open by an external toggle instead of a hover. Clicking a fanned card lifts it clear of its neighbours and flips it to the accent colour. Spacing is measured from the container at fan time, so the same markup fills a wide desktop stage and closes to a hand of cards on a phone. An optional scroll-scrubbed variant drives the identical layout from scroll position instead.

## Features

- Three fan shapes — spread, arc and cascade — set with data-fan-mode and switchable at runtime
- External controls: [data-fan-mode-control] buttons pick the shape, [data-fan-toggle] holds the deck open
- Spring physics via GSAP elastic easing, with per-card stagger out from the centre
- Click-to-front selection that lifts the card clear and flips it to the accent colour
- Fan width measured from the container, so end cards never overflow their stage
- Optional scroll-scrubbed variant that fans the same markup from scroll position
- Hover, keyboard focus and touch tap all open the deck
- Reduced-motion fallback lays every card out as a plain, readable grid

## Use Cases

- Service or capability decks on agency and studio sites
- Process steps that fan out from a single pile
- Pricing or plan cards that stay compact until someone looks at them
- Portfolio project stacks with a tactile, physical reveal
- Feature highlights that need to sit in a fixed-height section

## 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

Cards are absolutely positioned inside a flex-centred container and seated in a resting pile with small offsets, tilt and scale. On hover, focus, tap or an external toggle, the script measures the container and the card, subtracts an allowance for how much wider a tilted card is than its box, and hands the result to the selected shape function, which returns an x, y, rotation and scale per card. Each card animates there with elastic.out and a stagger that grows from the centre of the deck. Clicking a card raises its z-index and tweens it above its fanned position. The scroll variant feeds the same shape functions into a ScrollTrigger timeline with scrub instead of tweening on pointer events.

## 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="path/to/style.css">
```

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

```html
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
<!-- Only needed for the data-elastic-scroll variant. Safe to drop otherwise. -->
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/ScrollTrigger.min.js"></script>
<script src="path/to/script.js"></script>
```

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

```html
<div class="elastic-stack" id="capability-deck" data-elastic-hover data-fan-mode="spread"
     tabindex="0" role="group" aria-label="Capability cards. Hover or focus to fan them out.">
  <article class="elastic-card" tabindex="0">
    <span class="card-index">01</span>
    <h2 class="card-title">Research</h2>
    <p class="card-desc">Short supporting line.</p>
    <span class="card-tag">Discovery</span>
  </article>
  <!-- More .elastic-card elements -->
</div>
```

Buttons elsewhere on the page can drive it by pointing `data-target` at the deck's id:

```html
<button data-fan-mode-control data-target="capability-deck" data-mode="arc" aria-pressed="false">Arc</button>
<button data-fan-toggle data-target="capability-deck" aria-pressed="false">
  <span data-fan-toggle-label>Fan out</span>
</button>
```

### Options

#### On the `.elastic-stack`

| Attribute | Values | Default | Description |
|-----------|--------|---------|-------------|
| `data-elastic-hover` | — | — | Enables the hover / focus / tap fan |
| `data-elastic-scroll` | — | — | Enables the scroll-scrubbed variant instead (needs ScrollTrigger) |
| `data-fan-mode` | `spread`, `arc`, `cascade` | `spread` | Which shape the deck fans into |
| `id` | any | — | Required only if external controls target this deck |

#### Fan shapes

| Mode | Shape |
|------|-------|
| `spread` | Even horizontal fan, ends lifted, gentle outward tilt |
| `arc` | Same width, ends dropped along a curve with a stronger tilt and slight scale-down |
| `cascade` | Same width, laddered diagonally from top-left to bottom-right at a constant tilt |

All three use the same horizontal travel, so the amount of each card left
showing does not change when you switch shapes.

#### External controls

| Attribute | Element | Description |
|-----------|---------|-------------|
| `data-fan-mode-control` | `<button>` | Sets `data-fan-mode`; gets `.active` and `aria-pressed` managed for you |
| `data-fan-toggle` | `<button>` | Holds the deck open or closed regardless of hover; `aria-pressed` managed |
| `data-fan-toggle-label` | any child | Its text is swapped between "Fan out" and "Collapse" |
| `data-target` | either | The `id` of the deck the button drives |

#### Card count

3–8 cards. More cards means less of each one shows, so shorten the copy as the
count goes up.

### Accessibility

- **Reduced motion**: no fan at all. Every card is laid out in a plain wrapped grid, fully readable, with no transforms and no listeners attached
- **Keyboard**: focusing the stack or any card fans the deck; Enter or Space on a card selects it. Focus leaving the stack closes it again unless a toggle is holding it open
- **Touch**: tapping the deck toggles the fan. Card taps do not select, so a tap never traps you with a lifted card
- **Screen readers**: give the stack `role="group"` and an `aria-label` that says what the deck is and how it opens. The control buttons carry their own `aria-pressed` state

### Browser Support

Modern browsers (ES6+). Not compatible with IE11.

### Dependencies

**Required:**
- [GSAP 3.12+](https://gsap.com/) (core)

**Optional:**
- [ScrollTrigger](https://gsap.com/docs/v3/Plugins/ScrollTrigger/) — only for `data-elastic-scroll`
- [Lenis](https://lenis.darkroom.engineering/) — only for `data-elastic-scroll`

## 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 Elastic Stack Cards](https://gsapvault.com/effects/elastic-stack-cards)
- [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):

- [Scroll Progress Indicator](https://gsapvault.com/effects/scroll-progress.md): A precise GSAP reading-progress instrument with bar, ring, side rail, percentage, and active chapter feedback.
- [CSS Scroll Reveal](https://gsapvault.com/effects/css-scroll-reveal.md): Native CSS scroll-driven reveals for crisp fade, slide, and scale entrances with accessible static fallbacks and no animation JavaScript.
- [Parallax Hero](https://gsapvault.com/effects/parallax-hero.md): A pinned hero that separates its background photograph, copy, and foreground card into distinct scroll depths from a single scrubbed ScrollTrigger.

---

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