Expandable Card

A versatile and engaging UI component that allows users to explore content in a more immersive way. Click the card to expand and view detailed content with smooth layout animations.

Preview

Click a card to expand and view details. Press Escape or click outside to close.

Installation

Requires framer-motion for animations. Install it if not already present.

pnpm dlx shadcn@latest add https://zezo-ui.vercel.app/r/zezo-expandable-card.json

Usage

Works with IContentData (OTT). Map name, poster, description, and children for the expanded view.

import { ExpandableCard } from "@/components/ui/zezo-ui/Common/expandable-card"
import type { IContentData } from "@zezosoft/zezo-ott-api-client"

{contentData.map((item: IContentData) => (
  <ExpandableCard
    key={item._id}
    title={item.name}
    src={item.poster || item.thumbnail}
    description={`${item.content_duration} • ${item.release_year}`}
  >
    <h4>About</h4>
    <p>{item.description}</p>
  </ExpandableCard>
))}

Props

PropTypeRequiredDescription
titlestringYesCard title displayed in collapsed and expanded states
srcstringYesImage URL for the card
descriptionstringYesSubtitle or tagline shown below the image
childrenReactNodeNoContent revealed when the card is expanded
classNamestringNoAdditional CSS classes for the collapsed card
classNameExpandedstringNoAdditional CSS classes for the expanded card content