Back to Shark UI

Card

docs/components/card

latest8.8 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Card

Copy Markdown

Displays content about a single subject.

PreviewCode

Login to your account

Enter your email and check your inbox

Sign Up

Email

Send one-time codeLogin with Google

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/card

Anatomy#

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

Usage#

import { 
  Card, 
  CardContent, 
  CardDescription, 
  CardFooter, 
  CardHeader, 
  CardTitle, 
  CardAction,
  CardMedia,
} from "@/components/ui/card";
<Card>
  <CardMedia />
  <CardHeader>
    <CardTitle />
    <CardDescription />
    <CardAction />
  </CardHeader>
  <CardContent />
  <CardFooter />
</Card>

Title & Description#

CardHeader supports two usage patterns:

Using props#

Pass title and description props directly to CardHeader.

<CardHeader title="Card Title" description="Card description">
  <CardAction />
</CardHeader>

This approach does not require CardTitle or CardDescription components.

Using components#

Use CardTitle and CardDescription as children for more control.

<CardHeader>
  <CardTitle>Card Title</CardTitle>
  <CardDescription>Card description</CardDescription>
  <CardAction />
</CardHeader>

Examples#

Product card#

PreviewCode

Living room Sofa

This sofa is perfect for modern tropical spaces, baroque inspired spaces.

Buy nowAdd to cart

Icon card#

PreviewCode

Get 15% OFF

Minimum purchase of $100 required. Use code at checkout.

15OFF

Copy code

Custom spacing#

The [--space:--spacing("value")] on Card controls the internal spacing.

Default spacing is --spacing(6).

PreviewCode

Login to your account

Enter your email and check your inbox

Sign Up

Email

LoginLogin with Google

You can use breakpoint utilities to change the internal spacing at different screen sizes.

md:[--space:--spacing(6)] lg:[--space:--spacing(8)]

API Reference#

Card#

Root wrapper for card layout.

PropTypeDefault
classNamestring-
asChildbooleanfalse
CSS VariableDefault
--space--spacing(6)

CardMedia#

Image, video, or media area. Often full-width at top.

PropTypeDefault
variant`"default""icon"
classNamestring-
asChildbooleanfalse

CardHeader#

Header area. Typically holds title and optional actions.

PropTypeDefault
titlestring-
descriptionstring-
classNamestring-
asChildbooleanfalse

CardTitle#

Card title or heading. Bold by default.

PropTypeDefault
classNamestring-
asChildbooleanfalse

CardDescription#

Card description or body text. Muted foreground for hierarchy.

PropTypeDefault
classNamestring-
asChildbooleanfalse

CardAction#

Action button or link in the card header.

PropTypeDefault
classNamestring-
asChildbooleanfalse

CardContent#

Main body content of the card.

PropTypeDefault
classNamestring-
asChildbooleanfalse

CardFooter#

Footer area. Typically holds secondary actions or metadata.

PropTypeDefault
classNamestring-
asChildbooleanfalse

[

Previous page

Calendar ](/docs/components/calendar)[

Next page

Carousel ](/docs/components/carousel)

On This Page

InstallationAnatomyUsageTitle & DescriptionUsing propsUsing componentsExamplesProduct cardIcon cardCustom spacingAPI ReferenceCardCardMediaCardHeaderCardTitleCardDescriptionCardActionCardContentCardFooter