Files
lixiyu-net/components/ui/card.tsx

44 lines
1.7 KiB
TypeScript
Raw Normal View History

2024-01-09 16:57:38 +08:00
import * as React from "react";
import { cn } from "@/lib/utils";
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
2024-04-03 22:08:27 +08:00
<div className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)} ref={ref} {...props} />
2024-01-09 16:57:38 +08:00
));
Card.displayName = "Card";
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
2024-04-03 22:08:27 +08:00
<div className={cn("flex flex-col space-y-1.5 p-6", className)} ref={ref} {...props} />
2024-01-09 16:57:38 +08:00
),
);
CardHeader.displayName = "CardHeader";
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
({ className, ...props }, ref) => (
2024-04-03 22:08:27 +08:00
<h3 className={cn("text-2xl font-semibold leading-none tracking-tight", className)} ref={ref} {...props} />
2024-01-09 16:57:38 +08:00
),
);
CardTitle.displayName = "CardTitle";
const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
({ className, ...props }, ref) => (
2024-04-03 22:08:27 +08:00
<p className={cn("text-sm text-muted-foreground", className)} ref={ref} {...props} />
2024-01-09 16:57:38 +08:00
),
);
CardDescription.displayName = "CardDescription";
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
2024-04-03 22:08:27 +08:00
({ className, ...props }, ref) => <div className={cn("p-6 pt-0", className)} ref={ref} {...props} />,
2024-01-09 16:57:38 +08:00
);
CardContent.displayName = "CardContent";
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
2024-04-03 22:08:27 +08:00
<div className={cn("flex items-center p-6 pt-0", className)} ref={ref} {...props} />
2024-01-09 16:57:38 +08:00
),
);
CardFooter.displayName = "CardFooter";
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };