2
0

card.tsx 1.9 KB

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