Card

Displays a card with header, content, and footer.

Installation

Command

npx shadcn@latest add @fulldev/card

Manual

  1. Copy and paste the card component files into your project.
  2. Update the import paths to match your project setup.

Usage

import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
<Card>
  <CardHeader>
    <CardTitle>Card Title</CardTitle>
    <CardDescription>Card Description</CardDescription>
    <CardAction>Card Action</CardAction>
  </CardHeader>
  <CardContent>
    <p>Card Content</p>
  </CardContent>
  <CardFooter>
    <p>Card Footer</p>
  </CardFooter>
</Card>

Polymorphic

Card and CardTitle are polymorphic via as. Pass as to render another element and use the attributes for that element. Both render a div by default. A dl card holds dt and dd pairs, optionally wrapped in a div.

<Card as="article">...</Card>
<Card as="section" aria-labelledby="plan-title">...</Card>
<Card as="a" href="/pricing">...</Card>
<Card as="li">...</Card>
<Card as="dl">
  <div><dt>Plan</dt><dd>Pro</dd></div>
</Card>

<CardTitle as="h3">Card Title</CardTitle>

Composition

Use the following composition to build a Card:

Card
├── CardHeader
│   ├── CardTitle
│   ├── CardDescription
│   └── CardAction
├── CardContent
└── CardFooter

Examples

Image

Add an image before the card header to create a card with an image.

Article

Render the card as an article with a heading as its title.

Render the whole card as a link. Keep other links and buttons out of a link card.

List

Render cards as list items inside a ul.

API Reference

See the GitHub source code for more information on props.