Controls and surfaces
card
A flat surface with a hairline edge, and parts for a header, title, description, content and footer.
When to use it
Grouping related content: a plan, a stat, a form section. For a grid of unequal cards use bento-grid.
See it working
The demonstration the browser checks drive, with the keyboard as well as the pointer. More of it is on the Display page.
Card
Usage
Example figures, this month
62% of the plan used
Stat
Visitors
12,480
+8.2%than last month
Errors
31
−4than last week
Badge, avatar, kbd
SolidSoftOutlineLiveReviewFailed
AKHMRW
CtrlKLoadingor
Alert and empty state
Heads up
Billing moves to the first of the month.
Payment failed
Update the card to keep the site online.
No projects yet
Create one to see it here.
Table
| Name | Plan | Seats | Status |
|---|---|---|---|
| Example Studio | Team | 12 | Active |
| Example Bakery | Solo | 1 | Trial |
| Example Travel | Company | 48 | Active |
Add it
npx shadcn@latest add @rivier-ui/cardThe registry is named once in components.json: see Installation.
Example
Import it from @/components/ui/card.
<Card>
<CardHeader>
<CardTitle>Usage</CardTitle>
<CardDescription>This month</CardDescription>
</CardHeader>
<CardContent>1,204 requests</CardContent>
<CardFooter><Button size="sm">Details</Button></CardFooter>
</Card>What it needs
Plain markup: it can stay a server component. No packages beyond React.
It imports
Source
The whole file. Once copied it is yours: the registry item holds the same text.
/**
* @name card
* @category ui
* @description A flat surface with a hairline edge, and parts for a header, title, description, content and footer.
* @when Grouping related content: a plan, a stat, a form section. For a grid of unequal cards use bento-grid.
* @example
* <Card>
* <CardHeader>
* <CardTitle>Usage</CardTitle>
* <CardDescription>This month</CardDescription>
* </CardHeader>
* <CardContent>1,204 requests</CardContent>
* <CardFooter><Button size="sm">Details</Button></CardFooter>
* </Card>
*/
import type { ComponentProps } from "react";
import { cn } from "@/lib/cn";
export function Card({ className, ...props }: ComponentProps<"div">) {
return <div data-slot="card" className={cn("flex flex-col rounded-surface border bg-card text-card-foreground", className)} {...props} />;
}
export function CardHeader({ className, ...props }: ComponentProps<"div">) {
return <div data-slot="card-header" className={cn("flex flex-col gap-1 p-5", className)} {...props} />;
}
/** Renders an h3. Pass `asChild`-free: change the level by using your own heading with these classes if needed. */
export function CardTitle({ className, ...props }: ComponentProps<"h3">) {
return <h3 data-slot="card-title" className={cn("text-base font-medium leading-tight", className)} {...props} />;
}
export function CardDescription({ className, ...props }: ComponentProps<"p">) {
return <p data-slot="card-description" className={cn("text-sm text-muted-foreground", className)} {...props} />;
}
export function CardContent({ className, ...props }: ComponentProps<"div">) {
return <div data-slot="card-content" className={cn("p-5 pt-0 first:pt-5", className)} {...props} />;
}
export function CardFooter({ className, ...props }: ComponentProps<"div">) {
return <div data-slot="card-footer" className={cn("mt-auto flex items-center gap-2 border-t p-5", className)} {...props} />;
}