card.jsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import * as React from "react"
  2. import { cn } from "@/lib/utils"
  3. function Card({
  4. className,
  5. ...props
  6. }) {
  7. return (
  8. <div
  9. data-slot="card"
  10. className={cn(
  11. "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
  12. className
  13. )}
  14. {...props} />
  15. );
  16. }
  17. function CardHeader({
  18. className,
  19. ...props
  20. }) {
  21. return (
  22. <div
  23. data-slot="card-header"
  24. className={cn(
  25. "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
  26. className
  27. )}
  28. {...props} />
  29. );
  30. }
  31. function CardTitle({
  32. className,
  33. ...props
  34. }) {
  35. return (
  36. <div
  37. data-slot="card-title"
  38. className={cn("leading-none font-semibold", className)}
  39. {...props} />
  40. );
  41. }
  42. function CardDescription({
  43. className,
  44. ...props
  45. }) {
  46. return (
  47. <div
  48. data-slot="card-description"
  49. className={cn("text-muted-foreground text-sm", className)}
  50. {...props} />
  51. );
  52. }
  53. function CardAction({
  54. className,
  55. ...props
  56. }) {
  57. return (
  58. <div
  59. data-slot="card-action"
  60. className={cn(
  61. "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
  62. className
  63. )}
  64. {...props} />
  65. );
  66. }
  67. function CardContent({
  68. className,
  69. ...props
  70. }) {
  71. return (<div data-slot="card-content" className={cn("px-6", className)} {...props} />);
  72. }
  73. function CardFooter({
  74. className,
  75. ...props
  76. }) {
  77. return (
  78. <div
  79. data-slot="card-footer"
  80. className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
  81. {...props} />
  82. );
  83. }
  84. export {
  85. Card,
  86. CardHeader,
  87. CardFooter,
  88. CardTitle,
  89. CardAction,
  90. CardDescription,
  91. CardContent,
  92. }