Card
A 12px surface with a hairline ring, header, content and footer.
With header and footer
Website refresh
Due on 12 December
Fourteen of twenty tasks are done. Two invoices are issued and one is awaiting payment.
import { MoreHorizontalIcon } from "@keyline-icons/react"
import { Button } from "@/components/ui/button"
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
export default function CardWithHeaderAndFooter() {
return (
<Card className="w-full max-w-sm">
<CardHeader>
<CardTitle>Website refresh</CardTitle>
<CardDescription>Due on 12 December</CardDescription>
<CardAction>
<Button variant="ghost" size="icon-sm" aria-label="Project actions">
<MoreHorizontalIcon />
</Button>
</CardAction>
</CardHeader>
<CardContent>Fourteen of twenty tasks are done. Two invoices are issued and one is awaiting payment.</CardContent>
<CardFooter className="gap-2">
<Button>Open project</Button>
<Button variant="outline">Share</Button>
</CardFooter>
</Card>
)
}
Small
Open tasks
6
This week
Unpaid invoices
3
This week
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
const totals = [
{ label: "Open tasks", value: "6" },
{ label: "Unpaid invoices", value: "3" },
]
export default function CardSmall() {
return (
<div className="grid w-full max-w-sm grid-cols-2 gap-3">
{totals.map(({ label, value }) => (
<Card key={label} size="sm">
<CardHeader>
<CardDescription>{label}</CardDescription>
<CardTitle className="text-2xl tabular-nums">{value}</CardTitle>
</CardHeader>
<CardContent className="text-muted-foreground">This week</CardContent>
</Card>
))}
</div>
)
}
Divided
Invoice INV-0412
Issued on 1 November
- Design
- 840.00
- Development
- 400.00
Total 1,240.00
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
export default function CardDivided() {
return (
<Card className="w-full max-w-sm">
<CardHeader className="border-b">
<CardTitle>Invoice INV-0412</CardTitle>
<CardDescription>Issued on 1 November</CardDescription>
</CardHeader>
<CardContent>
<dl className="grid grid-cols-2 gap-y-1">
<dt className="text-muted-foreground">Design</dt>
<dd className="text-right tabular-nums">840.00</dd>
<dt className="text-muted-foreground">Development</dt>
<dd className="text-right tabular-nums">400.00</dd>
</dl>
</CardContent>
<CardFooter className="justify-between border-t">
<span className="font-medium tabular-nums">Total 1,240.00</span>
<Button variant="outline">Download PDF</Button>
</CardFooter>
</Card>
)
}
With an image
Release 4.2
Fourteen changes, shipped on Tuesday.
import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
const cover = `data:image/svg+xml,${encodeURIComponent(
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 160" preserveAspectRatio="none">
<defs>
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#5b45f5"/>
<stop offset="1" stop-color="#191919"/>
</linearGradient>
</defs>
<rect width="384" height="160" fill="url(#g)"/>
<path d="M0 120 64 96 128 108 192 70 256 82 384 30V160H0Z" fill="#fff" fill-opacity=".16"/>
</svg>`
)}`
export default function CardWithAnImage() {
return (
<Card className="w-full max-w-sm">
<img src={cover} alt="" className="h-40 w-full object-cover" />
<CardHeader>
<CardTitle>Release 4.2</CardTitle>
<CardDescription>Fourteen changes, shipped on Tuesday.</CardDescription>
</CardHeader>
</Card>
)
}
Installation
npx shadcn@latest add @khaeli/cardbunx --bun shadcn@latest add @khaeli/cardInstall @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.
Installs with
- Registry items
Accessible name
- A card is a plain
divandCardTitleis not a heading. Where the card opens a part of the page, put a heading element insideCardTitle. - An icon-only button in
CardActionneeds anaria-label.
Registry JSON
The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/card.json