SparkUI

Cards Stack

The Cards Stack Component is a visually engaging and interactive UI element designed to display a collection of cards in an overlapping, stacked format. This component enhances user interaction by allowing the cards to dynamically respond to user actions, creating a sense of depth and motion. Ideal for showcasing portfolios, product listings, or any content that benefits from a layered presentation.

Features :

  • Dynamic Interaction: The component leverages Framer Motion to provide smooth animations and transitions, making the card stack visually appealing and interactive.
  • Customizable Layout: Easily adjustable parameters such as spacing, alignment, and animation duration allow for fine-tuning the stack to match your design requirements.
  • Ease of Integration: Simple to integrate into any React application, with minimal setup required, making it accessible for developers of all skill levels.
  • Engaging Design: Adds a modern and sophisticated visual effect that enhances the overall aesthetics of your UI, making content more attractive and engaging.
  • Responsive and Accessible: Designed to be fully responsive and accessible, ensuring a consistent and user-friendly experience across different devices and screen sizes.
  • Delhi, India

    The capital city of India, Delhi, is a blend of historic and modern attractions. Visitors can explore ancient monuments like the Red Fort and Humayun's Tomb, or enjoy the vibrant street life in markets like Chandni Chowk. Delhi's diverse culture and rich history make it a fascinating destination.

    Taj Mahal, Agra

    One of the most iconic monuments in the world, the Taj Mahal is a stunning example of Mughal architecture. Built by Emperor Shah Jahan in memory of his wife Mumtaz Mahal, this white marble mausoleum attracts millions of visitors each year..

    Goa, India

    Famous for its beaches, Goa is a paradise for beach lovers. From the lively Baga Beach to the tranquil Palolem Beach, there is a spot for everyone. Goa also offers vibrant nightlife, colonial architecture, and lush greenery.

    Golden Temple, Amritsar

    The Golden Temple, or Harmandir Sahib, is the spiritual and cultural center of the Sikh religion. Its stunning golden architecture and serene surroundings make it a must-visit. The temple is known for its hospitality, serving free meals to thousands of visitors daily.

    Udaipur, Rajasthan

    Known as the City of Lakes, Udaipur is famous for its palaces and scenic beauty. The City Palace, overlooking Lake Pichola, offers a glimpse into the royal past of Rajasthan. Udaipur's romantic ambiance makes it a popular destination for couples.

    Install Dependencies
    npm install framer-motion lenis
    Copy the Source code`components/ui/card-stack.tsx`
    
    'use client'
    import Image from 'next/image';
    import { useTransform, motion, useScroll } from 'framer-motion';
    import { useRef } from 'react';
    
    export default function Card ({i, title, description, src, color, progress, range, targetScale}) {
    
      const container = useRef(null);
      const { scrollYProgress } = useScroll({
        target: container,
        offset: ['start end', 'start start']
      })
    
      const imageScale = useTransform(scrollYProgress, [0, 1], [2, 1])
      const scale = useTransform(progress, range, [1, targetScale]);
     
      return (
        <div ref={container} className={`h-screen flex items-center justify-center sticky top-0`}>
          <motion.div 
            style={{backgroundColor: color, scale, top:`calc(-5vh + ${i * 25}px)`}} 
            className={`flex flex-col relative  h-[70%] w-full rounded-3xl p-10 `} >
            <h2 className='text-center m-0 text-2xl'>{title}</h2>
            <div className={`flex flex-row h-full mt-10 gap-3`}>
              <div className={`w-full md:w-2/5 relative top-[10%]`}>
                <p className='text-base'>{description}</p>
              </div>
    
              <div className={`relative w-3/5 h-full rounded-md overflow-hidden hidden md:inline-block`}>
                <motion.div
                  className={`w-full h-full`}
                  style={{scale: imageScale}}
                >
                  <Image
                    fill
                    src={`/assests/images/cards-stack/${src}`}
                    alt="image"
                    className='object-cover'
                  />
                </motion.div>
              </div>
    
            </div>
          </motion.div>
        </div>
      )
    }
      
    SparkUI