card.tsx68 lines, 1.5 KB
| 1 | import * as React from "react" |
| 2 | |
| 3 | import { cn } from "@/lib/utils" |
| 4 | |
| 5 | function Card({ className, ...props }: React.ComponentProps<"div">) { |
| 6 | return ( |
| 7 | <div |
| 8 | data-slot="card" |
| 9 | className={cn( |
| 10 | "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm", |
| 11 | className |
| 12 | )} |
| 13 | {...props} |
| 14 | /> |
| 15 | ) |
| 16 | } |
| 17 | |
| 18 | function CardHeader({ className, ...props }: React.ComponentProps<"div">) { |
| 19 | return ( |
| 20 | <div |
| 21 | data-slot="card-header" |
| 22 | className={cn("flex flex-col gap-1.5 px-6", className)} |
| 23 | {...props} |
| 24 | /> |
| 25 | ) |
| 26 | } |
| 27 | |
| 28 | function CardTitle({ className, ...props }: React.ComponentProps<"div">) { |
| 29 | return ( |
| 30 | <div |
| 31 | data-slot="card-title" |
| 32 | className={cn("leading-none font-semibold", className)} |
| 33 | {...props} |
| 34 | /> |
| 35 | ) |
| 36 | } |
| 37 | |
| 38 | function CardDescription({ className, ...props }: React.ComponentProps<"div">) { |
| 39 | return ( |
| 40 | <div |
| 41 | data-slot="card-description" |
| 42 | className={cn("text-muted-foreground text-sm", className)} |
| 43 | {...props} |
| 44 | /> |
| 45 | ) |
| 46 | } |
| 47 | |
| 48 | function CardContent({ className, ...props }: React.ComponentProps<"div">) { |
| 49 | return ( |
| 50 | <div |
| 51 | data-slot="card-content" |
| 52 | className={cn("px-6", className)} |
| 53 | {...props} |
| 54 | /> |
| 55 | ) |
| 56 | } |
| 57 | |
| 58 | function CardFooter({ className, ...props }: React.ComponentProps<"div">) { |
| 59 | return ( |
| 60 | <div |
| 61 | data-slot="card-footer" |
| 62 | className={cn("flex items-center px-6", className)} |
| 63 | {...props} |
| 64 | /> |
| 65 | ) |
| 66 | } |
| 67 | |
| 68 | export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } |