Skip to content

Card

A bordered box for dashboards, pricing tiers, and product grids — header, content, and footer with the neobrutalist hard-shadow treatment.

import { Button } from "@/components/ui/button"
import {
  Card,

The card groups related content into a self-contained box with optional header, content, and footer slots. There is no primitive underneath — it is plain markup styled to the neobrutalist recipe: a thick border, a hard offset shadow, and a heading-font title.

Reach for it when:

  • Dashboard panels — stat tiles, charts, and activity feeds arranged in a grid.
  • Pricing tiers — plan name and price in the header, features in the body, the buy button in the footer.
  • Standalone forms — login, sign-up, and settings boxes that need a visual boundary.

Installation

pnpm dlx shadcn@latest add https://neobrutalism.com/r/base/card.json
npx shadcn@latest add https://neobrutalism.com/r/base/card.json
yarn dlx shadcn@latest add https://neobrutalism.com/r/base/card.json
bunx --bun shadcn@latest add https://neobrutalism.com/r/base/card.json

Copy and paste the following code into your project.

components/ui/card.tsx
import * as React from "react"

import { cn } from "@/lib/utils"

function Card({
  className,
  size = "default",
  ...props
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
  return (
    <div
      data-slot="card"
      data-size={size}
      className={cn(
        "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded border-2 bg-card py-(--card-spacing) text-sm text-card-foreground shadow-md [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
        className
      )}
      {...props}
    />
  )
}

function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-header"
      className={cn(
        "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
        className
      )}
      {...props}
    />
  )
}

function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-title"
      className={cn(
        "cn-font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
        className
      )}
      {...props}
    />
  )
}

function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-description"
      className={cn("text-sm text-muted-foreground", className)}
      {...props}
    />
  )
}

function CardAction({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-action"
      className={cn(
        "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
        className
      )}
      {...props}
    />
  )
}

function CardContent({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-content"
      className={cn("px-(--card-spacing)", className)}
      {...props}
    />
  )
}

function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-footer"
      className={cn(
        "flex items-center rounded-b-xl border-t-2 bg-muted/50 p-(--card-spacing)",
        className
      )}
      {...props}
    />
  )
}

export {
  Card,
  CardHeader,
  CardFooter,
  CardTitle,
  CardAction,
  CardDescription,
  CardContent,
}

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>

Composition

Use the following composition to build a Card:

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

Examples

Size

Use the size="sm" prop to set the size of the card to small. The small size variant uses smaller spacing.

import { ChevronRightIcon } from "lucide-react"

import { Button } from "@/components/ui/button"

Spacing

In addition to the size prop, you can use the --card-spacing CSS variable to control the spacing between sections and the inset of card parts.

"use client"

import * as React from "react"

Use negative margins with -mx-(--card-spacing) to make content go edge to edge while keeping it aligned with the card inset. When the edge-to-edge content sits above a footer, use -mb-(--card-spacing) on CardContent to remove the section gap.

import { Button } from "@/components/ui/button"
import {
  Card,

Image

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

import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {

RTL

To enable RTL support in Neobrutalism.com, see the RTL configuration guide.

"use client"

import * as React from "react"

Accessibility

The card is purely presentational — every part renders a plain <div> with no implicit role, so it adds nothing to the accessibility tree. CardTitle is not a heading element: nest a real <h2><h4> inside it when the title should appear in the document outline. For clickable cards, put the link or button inside the card and stretch its hit area over the surface — never attach onClick to the card <div> itself.

API Reference

Card

The Card component is the root container for card content.

PropTypeDefault
size"default" | "sm""default"
classNamestring-

CardHeader

The CardHeader component is used for a title, description, and optional action.

PropTypeDefault
classNamestring-

CardTitle

The CardTitle component is used for the card title.

PropTypeDefault
classNamestring-

CardDescription

The CardDescription component is used for helper text under the title.

PropTypeDefault
classNamestring-

CardAction

The CardAction component places content in the top-right of the header (for example, a button or a badge).

PropTypeDefault
classNamestring-

CardContent

The CardContent component is used for the main card body.

PropTypeDefault
classNamestring-

CardFooter

The CardFooter component is used for actions and secondary content at the bottom of the card.

PropTypeDefault
classNamestring-

Changelog

Spacing Variable

If you're upgrading from a previous version of the Card component, you'll need to apply the following updates to use the --card-spacing variable:

Update the Card root spacing classes.

Replace the hard-coded gap and vertical padding with --card-spacing, and set the default and small size values on the root:

  className={cn(
-   "group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
+   "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
    className
  )}

Update CardHeader spacing classes.

Replace the horizontal padding and border spacing with the shared variable:

  className={cn(
-   "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
+   "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
    className
  )}

Update CardContent and CardFooter spacing classes.

Use --card-spacing for the content inset and footer padding:

  function CardContent({ className, ...props }: React.ComponentProps<"div">) {
    return (
      <div
        data-slot="card-content"
-       className={cn("px-4 group-data-[size=sm]/card:px-3", className)}
+       className={cn("px-(--card-spacing)", className)}
        {...props}
      />
    )
  }
  className={cn(
-   "flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",
+   "flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",
    className
  )}

After applying these changes, you can customize card spacing by setting --card-spacing on the Card with an arbitrary property class:

function Example() {
  return <Card className="[--card-spacing:--spacing(6)]">...</Card>
}