card.tsx91 lines, 1.9 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 border border-border/60", |
| 11 | "transition-all duration-200 ease-out", |
| 12 | "dark:bg-card dark:border-border/50", |
| 13 | className, |
| 14 | )} |
| 15 | {...props} |
| 16 | /> |
| 17 | ); |
| 18 | } |
| 19 | |
| 20 | function CardHeader({ className, ...props }: React.ComponentProps<"div">) { |
| 21 | return ( |
| 22 | <div |
| 23 | data-slot="card-header" |
| 24 | className={cn("flex flex-col gap-1.5 p-6", className)} |
| 25 | {...props} |
| 26 | /> |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | function CardTitle({ className, ...props }: React.ComponentProps<"div">) { |
| 31 | return ( |
| 32 | <div |
| 33 | data-slot="card-title" |
| 34 | className={cn("font-semibold leading-none tracking-tight", className)} |
| 35 | {...props} |
| 36 | /> |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | function CardDescription({ className, ...props }: React.ComponentProps<"div">) { |
| 41 | return ( |
| 42 | <div |
| 43 | data-slot="card-description" |
| 44 | className={cn("text-muted-foreground text-sm", className)} |
| 45 | {...props} |
| 46 | /> |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | function CardAction({ className, ...props }: React.ComponentProps<"div">) { |
| 51 | return ( |
| 52 | <div |
| 53 | data-slot="card-action" |
| 54 | className={cn( |
| 55 | "col-start-2 row-span-2 row-start-1 self-start justify-self-end", |
| 56 | className, |
| 57 | )} |
| 58 | {...props} |
| 59 | /> |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | function CardContent({ className, ...props }: React.ComponentProps<"div">) { |
| 64 | return ( |
| 65 | <div |
| 66 | data-slot="card-content" |
| 67 | className={cn("px-6", className)} |
| 68 | {...props} |
| 69 | /> |
| 70 | ); |
| 71 | } |
| 72 | |
| 73 | function CardFooter({ className, ...props }: React.ComponentProps<"div">) { |
| 74 | return ( |
| 75 | <div |
| 76 | data-slot="card-footer" |
| 77 | className={cn("flex items-center px-6 [.border-t]:pt-6", className)} |
| 78 | {...props} |
| 79 | /> |
| 80 | ); |
| 81 | } |
| 82 | |
| 83 | export { |
| 84 | Card, |
| 85 | CardHeader, |
| 86 | CardFooter, |
| 87 | CardTitle, |
| 88 | CardAction, |
| 89 | CardDescription, |
| 90 | CardContent, |
| 91 | }; |