INFINITYUI
HomeComponentsDocsTemplates
Star

Getting Started

  • Introduction
  • Installation
  • CLI
  • Audit

Navigation

  • Spotlight Navbar
  • Glass DockNEW
  • Animated Tab Bar
  • Circle Menu
  • Magnet Tabs
  • Animated Sidebar
  • Apple Spotlight
  • Page TOC RailNEW

Text

  • Flip Text
  • Glitch Text
  • Liquid Text
  • Flip Fade Text
  • Mask Cursor Effect

Cards

  • Glow Border Card
  • Testimonials Card
  • Interactive Book
  • Trading CardsNEW
  • Hover Image
  • Chain of ThoughtNEW
  • Masonry Grid
  • Image Pile
  • Staggered Grid

Inputs

  • AI InputNEW
  • OTP Input
  • Leave Rating

Buttons

  • Social Flip Button
  • Creepy Button

Loaders

  • Jelly Loader
  • Rolling Ball Scroll
  • Glowing Scroll

Backgrounds

  • Light Lines
  • Perspective Grid
  • Liquid Ocean
  • Eagle Vision
  • Flow Scroll
  • Horizontal Scroll

Overlays

  • PersonaNEW
  • Infinite Moving Cards
  • Masked Avatars
  • Stacked Logos
  • Icon Wheel
  • Pixelated CarouselNEW
  • Pixelated Image Trail
  • Flip Scroll
  • Interactive Folder
  • Animated Folder IconNEW
  • Stack Scroll
  • Rubik Cube
Cards

Image Pile

#image#pile#stack

Click a photo to lift it

Mountain
Ocean
Forest
Desert
implementedInfinityUI component

This component is fully implemented in InfinityUI and wired into the docs and registry flow.

Installation

Use the registry command to add the component source, and install any package dependencies if needed.

Infinity Registry

Install the component source into your project with the shadcn CLI.

npx shadcn@latest add https://infinityui-pearl.vercel.app/r/image-pile
Package Dependencies

Install the npm packages used by this component source.

npm install framer-motion

Component Code

Copy and paste this code into your component file.

tsx
"use client";

import { useState } from "react";
import { motion } from "framer-motion";

interface ImagePileProps {
    images: Array<{ src: string; alt: string }>;
}

export function ImagePile({ images }: ImagePileProps) {
    const [picked, setPicked] = useState<number | null>(null);

    // Preset random rotations for each image in the pile
    const rotations = [-8, 4, -3, 7, -5, 2];

    return (
        <div
            className="relative flex items-center justify-center"
            style={{ width: 260, height: 300 }}
        >
            {images.slice(0, 6).map((img, i) => {
                const isPicked = picked === i;
                const rot = rotations[i % rotations.length];
                const zIndex = picked === null ? images.length - i : isPicked ? 20 : images.length - i;

                return (
                    <motion.div
                        key={i}
                        className="absolute w-48 h-60 rounded-xl overflow-hidden shadow-2xl border border-white/10 cursor-pointer"
                        initial={{ rotate: rot }}
                        animate={{
                            rotate: isPicked ? 0 : rot,
                            y: isPicked ? -60 : 0,
                            scale: isPicked ? 1.08 : 1 - i * 0.02,
                            zIndex,
                        }}
                        whileHover={{ scale: isPicked ? 1.08 : (1 - i * 0.02) + 0.03 }}
                        transition={{ type: "spring", stiffness: 400, damping: 30 }}
                        onClick={() => setPicked(isPicked ? null : i)}
                        style={{ zIndex }}
                    >
                        <img src={img.src} alt={img.alt} className="w-full h-full object-cover" />
                    </motion.div>
                );
            })}
        </div>
    );
}