import { useState, type ReactNode } from 'react' interface CardProps { title?: ReactNode subtitle?: ReactNode actions?: ReactNode children: ReactNode className?: string /** Render the header as a show/hide toggle for the body. */ collapsible?: boolean /** Initial open state when collapsible (default: closed). */ defaultOpen?: boolean } export default function Card({ title, subtitle, actions, children, className, collapsible = false, defaultOpen = false, }: CardProps) { const [open, setOpen] = useState(defaultOpen) const isOpen = !collapsible || open const titleNode = collapsible ? ( ) : ( title &&

{title}

) return (
{(title || (actions && isOpen)) && (
{titleNode}
{actions && isOpen &&
{actions}
}
)} {isOpen && ( <> {subtitle &&

{subtitle}

} {children} )}
) }