BloksOrganismCard Stack

Card Stack

Description

The Card Stack component is a dynamic, scroll-activated element that displays a series of cards in a stacked layout. As the user scrolls, each card animates into view and then out, creating an engaging and interactive visual experience. The component allows for customization of card alignment and content, making it versatile for various use cases such as product showcases, feature highlights, or storytelling sections on a webpage.

Installation

bash
sabaccui add cardStack

Usage

Here's an example of how to use the Card Stack component in a Storyblok block:

Preview

Product 1

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.

Product 2

Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.

Schema

Field NameTypeDescriptionDefault Value
cardsbloksAn array of card components to be displayed in the stack. Only allows card components.-
alignoptionDetermines the alignment of the cards. Options are 'Left' or 'Right'."left"

Notes

  1. The Card Stack component uses the useScrollProgress composable to track scroll progress and animate the cards accordingly.
  2. Each card in the stack is represented by a CardStackCard component, which handles the individual card layout and animations.
  3. The component calculates progress for each card based on the scroll position, creating a smooth transition effect as cards enter and leave the viewport.
  4. CSS variables are used extensively to control the animations and transformations of each card.

Best Practices:

  • Limit the number of cards in a stack to maintain performance and avoid overwhelming the user.
  • Ensure that the content for each card is concise and visually appealing to make the most of the limited viewport space.
  • Consider the overall page layout when choosing between left and right alignment for the card stack.
  • Optimize images used in cards to ensure fast loading times and smooth scrolling performance.