Modus UI

Bounce Cards

Web (React)

A stack of playing cards that fan out and straighten out interactively when hovered.

A stack of playing cards that fan out and straighten out interactively when hovered. This component dynamically calculates transform positions and spring physics using purely Framer Motion, skipping heavy libraries like GSAP.

Installation

CLI

npx @modus-ui/cli add bounce-cards

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/bounce-cards.tsx.
  3. Paste the code.

Usage

tsx
import { BounceCards } from "@/components/ui/bounce-cards";

export default function Example() {
  const images = ["https://...", "https://..."];

  return (
    <BounceCards
      images={images}
      containerWidth={500}
      containerHeight={400}
      animationDelay={0.2}
      animationStagger={0.08}
      enableHover={true}
    />
  );
}

Props

PropTypeDefaultDescription
imagesstring[][]Image URLs for the cards.
containerWidthnumber | string400Width of the container.
containerHeightnumber | string400Height of the container.
animationDelaynumber0.5Delay in seconds before the cards bounce in.
animationStaggernumber0.06Delay in seconds between each card.
enableHoverbooleanfalseSpreads the cards apart when one is hovered.
transformStylesstring[][...]CSS transform for each card's resting position.

Comments

  • No comments yet.