NEW
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
shadcn registry is live·
Learn more
Skip to content
Docs

Card Spread

A stack of cards that will reveal on hover and spread on click.

Loading...

Installation

CLI

pnpm dlx shadcn@latest add https://animata.design/r/card/card-spread.json

Manual

Run the following command

It will create a new file card-spread.tsx inside the components/animata/card directory.

mkdir -p components/animata/card && touch components/animata/card/card-spread.tsx

Paste the code

Open the newly created file and paste the following code:

import { useState } from "react";
 
import Notes, { NotesCard } from "@/animata/widget/notes";
import ShoppingList from "@/animata/widget/shopping-list";
import { cn } from "@/lib/utils";
 
function Reminders() {
  return (
    <ShoppingList
      title="Reminders"
      data={[
        { title: "book museum tickets" },
        { title: "buy groceries", checked: true },
        { title: "call mom" },
      ]}
    />
  );
}
 
function RemodelNotes() {
  return (
    <NotesCard title="Kitchen Remodel Ideas">
      <div>Install a farmhouse sink for a rustic touch</div>
      <div>Use classic subway tiles</div>
      <div>Add an island for extra counter space</div>
      <div>Opt for open shelving</div>
    </NotesCard>
  );
}
 
const cards = [
  {
    component: Notes,
    rotationClass: "",
    revealClass: "-rotate-[2deg]",
  },
  {
    component: ShoppingList,
    rotationClass: "group-hover/spread:rotate-[15deg]",
    revealClass: "rotate-[3deg] translate-y-2",
  },
 
  {
    component: RemodelNotes,
    rotationClass: "group-hover/spread:rotate-[30deg]",
    revealClass: "-rotate-[2deg] translate-x-1",
  },
 
  {
    component: Reminders,
    rotationClass: "group-hover/spread:rotate-[45deg]",
    revealClass: "rotate-[2deg]",
  },
];
 
export default function CardSpread() {
  const [isExpanded, setExpanded] = useState(false);
 
  return (
    <div
      className={cn(
        "group/spread relative flex min-h-80 min-w-52 items-center transition duration-500 ease-in-out",
        {
          "origin-bottom transition duration-500 ease-in-out hover:-rotate-[15deg]": !isExpanded,
          "gap-3": isExpanded,
        },
      )}
    >
      {cards.map((item, index) => {
        return (
          <div
            key={index}
            onClick={(e) => {
              setExpanded(!isExpanded);
              e.preventDefault();
            }}
            className={cn(
              "transition duration-500 ease-in-out",
              {
                absolute: !isExpanded,
                "origin-bottom": !isExpanded,
              },
              !isExpanded && item.rotationClass,
              isExpanded && item.revealClass,
            )}
          >
            <item.component />
          </div>
        );
      })}
    </div>
  );
}

Credits

Built by sudha