Expandable Card Title
Click to expand and see more details
This is the expandable content that appears when you click the card. It smoothly animates in and out using the ElasticHeight component.
This is the expandable content that appears when you click the card. It smoothly animates in and out using the ElasticHeight component.
'use client';
import { ExpandableCard } from '@/ui/cards/ExpandableCard';
export function ExpandableCardDemo() {
return (
<ExpandableCard title="Expandable Card Title" subtitle="Click to expand and see more details">
<div className="p-20">
<p className="text-grey">
This is the expandable content that appears when you click the card. It smoothly animates
in and out using the ElasticHeight component.
</p>
</div>
</ExpandableCard>
);
}
npx shadcn@latest add https://develop.trident-ui.pro.clubmed/r/expandable-card.json
import { ExpandableCard } from '@/docs/lib/ui/expandable-card';
export function Component() {
return (
<ExpandableCard
title="Explore the Mediterranean"
subtitle="Discover amazing destinations"
image={{
src: '/images/destination.jpg',
alt: 'Mediterranean coast',
}}
tags={[
{
label: 'All Inclusive',
backgroundColor: 'saffron',
color: 'black',
},
]}
onClick={(isExpanded) => {
console.log('Card expanded:', isExpanded);
}}
>
<div className="p-20">
<p>
Experience pristine beaches, crystal-clear waters, and world-class amenities at our
Mediterranean resorts.
</p>
</div>
</ExpandableCard>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
title | string | undefined | Required. The main heading text displayed in the card. |
subtitle | string | null | undefined | Optional subtitle text displayed below the title. |
hLevel | 1 | 2 | 3 | 4 | 5 | 6 | 3 | The semantic heading level for the title (h1-h6). |
image | CardBackgroundProps | undefined | Optional background image configuration. When provided, renders an image with a gradient overlay and changes text color to white. |
tags | ComponentProps<typeof Tag>[] | null | undefined | Optional array of tag configurations to display at the top of the card. |
onClick | (isExpanded: boolean) => void | undefined | Optional callback function that fires when the card is clicked. Receives the new expanded state as a parameter. |
component | string | "article" | The HTML element type to render as the root element. |
children | ReactNode | undefined | The collapsible content that appears when the card is expanded. Smoothly animates using ElasticHeight. |
className | string | undefined | Additional CSS classes to apply to the root card element. |
The component also accepts all standard HTML element attributes based on the component prop (defaults to article attributes) via CardProps.
useState hook.ElasticHeight component to provide smooth height transitions when expanding and collapsing content.Clickable component, making it fully keyboard accessible with proper ARIA attributes.<article> element, but can be customized via the component prop for different semantic contexts.Card component, including themes (bordered, frame, none) and formats (horizontal, vertical, square, custom).onClick callback receives the new expanded state (true/false), allowing parent components to react to state changes.border-t-0) for a seamless visual appearance.data-name="ExpandableCard" and data-open={isExpanded} attributes for styling and testing purposes.