Browse the docs
ComponentsNo. 11 of 109
Card
Container with header, title, description, action, content and footer parts.
Installation
pnpm dlx shadcn@latest add @corsair-ui/cardNo setup needed: the CLI finds @corsair-ui in the shadcn registry directory. The files land in your project as source: edit them like your own code. More in Installation.
- Also adds
- utils
- npm
clsxtailwind-merge
Examples
With action and footer
Notifications
You have 3 unread messages.
Your booking for Saturday at 19:00 was confirmed.
Sign in
Sign in
Use the email you signed up with.
Accessibility
- Plain layout: use a heading inside CardTitle when the card starts a section.
Compatibility
- Tailwind CSS
- 3.4 and 4, both checked in CI
- React
- 19
- Rendering
- Works in server components
Source
1 file, installed as source you own
card.tsxView on GitHubimport type { ComponentProps } from "react";
import { cn } from "@/registry/default/lib/utils";
function Card({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="card"
className={cn(
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6",
className
)}
{...props}
/>
);
}
/** Title and description on the left; a CardAction, if present, sits on the right. */
function CardHeader({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="card-header"
className={cn(
"grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6",
"has-[[data-slot=card-action]]:grid-cols-[1fr_auto]",
className
)}
{...props}
/>
);
}
function CardTitle({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="card-title"
className={cn("leading-none font-semibold", className)}
{...props}
/>
);
}
function CardDescription({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="card-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
);
}
function CardAction({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="card-action"
className={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)}
{...props}
/>
);
}
function CardContent({ className, ...props }: ComponentProps<"div">) {
return <div data-slot="card-content" className={cn("px-6", className)} {...props} />;
}
function CardFooter({ className, ...props }: ComponentProps<"div">) {
return (
<div data-slot="card-footer" className={cn("flex items-center px-6", className)} {...props} />
);
}
export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };