View fulldotdev/ui on GitHub

Card

Displays a card with header, content, and footer.

Installation

npx shadcn@latest add @fulldev/card

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. Both render a div by default. A dl card holds dt and dd pairs, optionally wrapped in a div. Keep other links and buttons out of a link card.

<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

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

Size

Use size="sm" for a small card with tighter spacing.

Spacing

Set the --card-spacing CSS variable to control the gap between sections and the inset of card parts.

Use -mx-(--card-spacing) to make content go edge to edge, and -mb-(--card-spacing) on CardContent when that content sits above a footer.

Image

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

RTL

API Reference

Source: src/components/ui/card

Card

PropTypeDefault
size"default" | "sm""default"
asHTML tag"div"

CardTitle

PropTypeDefault
asHTML tag"div"

CardHeader, CardDescription, CardAction, CardContent and CardFooter render a div and take its attributes.