Make your AI a shadcn expert

Shadcn Card

React card for login forms, settings, and product tiles. Built with TypeScript and Tailwind CSS for Next.js using Base UI — header, content, footer, and an action slot.

A card is a bordered box with a header, a body, and a footer. Title and description stack in the header; CardAction pins a button or badge on the end. Use one card per topic — a login, a setting, a product.

Scroll to load preview...

Looking for a neobrutalism version for shadcn?

Same card, thicker borders. The NeoBrutalism card is the kit if you want that look.

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>

CardAction sits in the header end column. Every part is a div.

Composition

CardTitle
CardDescription
CardAction
CardContent
CardFooter

Size

There is no size prop. gap-3 py-3 on Card and px-3 on the parts is the compact look.

Scroll to load preview...

Spacing

Default is gap-6 py-6 and px-6 on the parts. Override those classes — this file does not read --card-spacing.

Scroll to load preview...

-mx-6 pulls a child to the edges. -mb-6 on CardContent closes the gap above the footer.

Scroll to load preview...

Image

Put the <img> before CardHeader. pt-0 overflow-hidden so it sits flush and clips the radius.

Scroll to load preview...

RTL

Wrap with DirectionProvider and dir="rtl". Use ms-auto, not ml-auto, so the end-aligned link stays on the end.

Scroll to load preview...

API

Prop

Type

CardHeader, CardTitle, CardDescription, CardContent, and CardFooter take className. CardAction is the header end slot.

Notes

Don't nest buttons in a link

If the whole card is an <a>, keep actions as text. A button inside a link is invalid HTML and two click targets.

CardAction only lands in the header grid. Put it inside CardHeader.

With other components

Questions

Was this page helpful?

Sign in to leave feedback.