import * as React from "react"; import { cn } from "../../lib/utils"; interface CardProps extends React.HTMLAttributes { /** Makes the card have a hover effect */ hoverable?: boolean; /** Makes the card have a bordered appearance */ bordered?: boolean; /** Renders the card with compact padding */ compact?: boolean; } const Card = React.forwardRef< HTMLDivElement, CardProps >(({ className, hoverable = false, bordered = false, compact = false, ...props }, ref) => (
)); Card.displayName = "Card"; interface CardHeaderProps extends React.HTMLAttributes { /** Adjusts the spacing in the header */ spacing?: "default" | "compact" | "relaxed"; } const CardHeader = React.forwardRef< HTMLDivElement, CardHeaderProps >(({ className, spacing = "default", ...props }, ref) => { const spacingClasses = { compact: "flex flex-col space-y-1 p-4", default: "flex flex-col space-y-1.5 p-6", relaxed: "flex flex-col space-y-2 p-8", }; return (
); }); CardHeader.displayName = "CardHeader"; interface CardTitleProps extends React.HTMLAttributes { /** HTML heading level to use */ as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6"; /** Adjusts the text size */ size?: "sm" | "default" | "lg"; } const CardTitle = React.forwardRef< HTMLParagraphElement, CardTitleProps >(({ className, as = "h3", size = "default", ...props }, ref) => { const Component = as; const sizeClasses = { sm: "text-lg", default: "text-2xl", lg: "text-3xl" }; return ( ); }); CardTitle.displayName = "CardTitle"; interface CardDescriptionProps extends React.HTMLAttributes { /** Makes text smaller or larger */ size?: "xs" | "sm" | "default"; } const CardDescription = React.forwardRef< HTMLParagraphElement, CardDescriptionProps >(({ className, size = "default", ...props }, ref) => { const sizeClasses = { xs: "text-xs", sm: "text-sm", default: "text-sm" }; return (

); }); CardDescription.displayName = "CardDescription"; interface CardContentProps extends React.HTMLAttributes { /** Removes the top padding when used after CardHeader */ removeTopPadding?: boolean; /** Adjusts content padding */ padding?: "none" | "sm" | "default" | "lg"; } const CardContent = React.forwardRef< HTMLDivElement, CardContentProps >(({ className, removeTopPadding = true, padding = "default", ...props }, ref) => { const paddingClasses = { none: "p-0", sm: "px-4 py-3", default: "p-6", lg: "p-8" }; return (

); }); CardContent.displayName = "CardContent"; interface CardFooterProps extends React.HTMLAttributes { /** Changes the alignment of footer items */ align?: "start" | "center" | "end" | "between" | "around"; /** Changes the direction of footer items */ direction?: "row" | "column"; } const CardFooter = React.forwardRef< HTMLDivElement, CardFooterProps >(({ className, align = "center", direction = "row", ...props }, ref) => { const alignClasses = { start: "justify-start", center: "justify-center", end: "justify-end", between: "justify-between", around: "justify-around" }; const directionClasses = { row: "flex-row", column: "flex-col" }; return (
); }); CardFooter.displayName = "CardFooter"; export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };