card.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import * as React from "react";
  2. import { cn } from "@/lib/utils";
  3. const Card = React.forwardRef<
  4. HTMLDivElement,
  5. React.HTMLAttributes<HTMLDivElement>
  6. >(({ className, ...props }, ref) => (
  7. <div
  8. ref={ref}
  9. className={cn(
  10. "rounded-lg border bg-card text-card-foreground shadow-sm transition-all duration-300",
  11. className
  12. )}
  13. {...props}
  14. />
  15. ));
  16. Card.displayName = "Card";
  17. const CardHeader = React.forwardRef<
  18. HTMLDivElement,
  19. React.HTMLAttributes<HTMLDivElement>
  20. >(({ className, ...props }, ref) => (
  21. <div
  22. ref={ref}
  23. className={cn("flex flex-col space-y-1.5 p-6", className)}
  24. {...props}
  25. />
  26. ));
  27. CardHeader.displayName = "CardHeader";
  28. const CardTitle = React.forwardRef<
  29. HTMLParagraphElement,
  30. React.HTMLAttributes<HTMLHeadingElement>
  31. >(({ className, ...props }, ref) => (
  32. <h3
  33. ref={ref}
  34. className={cn(
  35. "text-2xl font-semibold leading-none tracking-tight",
  36. className
  37. )}
  38. {...props}
  39. />
  40. ));
  41. CardTitle.displayName = "CardTitle";
  42. const CardDescription = React.forwardRef<
  43. HTMLParagraphElement,
  44. React.HTMLAttributes<HTMLParagraphElement>
  45. >(({ className, ...props }, ref) => (
  46. <p
  47. ref={ref}
  48. className={cn("text-sm text-muted-foreground", className)}
  49. {...props}
  50. />
  51. ));
  52. CardDescription.displayName = "CardDescription";
  53. const CardContent = React.forwardRef<
  54. HTMLDivElement,
  55. React.HTMLAttributes<HTMLDivElement>
  56. >(({ className, ...props }, ref) => (
  57. <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
  58. ));
  59. CardContent.displayName = "CardContent";
  60. const CardFooter = React.forwardRef<
  61. HTMLDivElement,
  62. React.HTMLAttributes<HTMLDivElement>
  63. >(({ className, ...props }, ref) => (
  64. <div
  65. ref={ref}
  66. className={cn("flex items-center p-6 pt-0", className)}
  67. {...props}
  68. />
  69. ));
  70. CardFooter.displayName = "CardFooter";
  71. export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };