Skip to content
Thrum

Card

A bordered panel for one subject: a metric with its note, a small form, a setting. It is made of parts, so leave out what you do not need. For a single figure with its trend, the stat card is ready-made.

Install

npx shadcn@latest add https://thrumui.dev/r/card.json

Adds components/ui/card.tsx. Nothing else in your project changes.

import { Card } from "@/components/ui/card";

Props

PropTypeDefaultDescription
CardComponentProps<"div">–The panel: border, card colour, 16 pixels between its parts. Set the width with className.
CardHeaderComponentProps<"div">–Holds the title and description, with a column on the right for CardAction.
CardTitleComponentProps<"div">–The card's name, 16 pixels and semibold. Put a heading element inside it when the card is a section of the page.
CardDescriptionComponentProps<"div">–One line under the title in the muted text colour.
CardActionComponentProps<"div">–A button or menu in the header's top right corner.
CardContentComponentProps<"div">–The body, with the same side padding as the header.
CardFooterComponentProps<"div">–A row for actions or a note at the bottom.
classNamestring–On every part: extra classes, merged last.

Motion and sound

Motion

  • The card does not move.

Sound

Silent. This component makes no sound.

Accessibility

  • The card is a plain div: it adds no role. When it is a section of the page, put a heading inside CardTitle, or give the card role="region" and an aria-label.
  • Text uses the card's foreground and muted colours, which keep 4.5 to 1 against the card in both themes.
  • Under a glass material the card becomes translucent. Its tint is high enough that the text keeps its contrast over any background.
  • Long titles and descriptions wrap. Nothing is cut off at 200 pixels wide.

Source

components/ui/card.tsx
"use client";

import type { ComponentProps } from "react";

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

/**
 * A bordered surface that groups one subject: a metric, a form, a setting.
 * Build it from the parts below. It is a panel surface, so it turns to glass when the page's material asks for it.
 */
export function Card({ className, ...props }: ComponentProps<"div">) {
  return <div data-slot="card" data-surface="panel" className={cn("flex flex-col gap-4 rounded-lg border bg-card py-4 text-card-foreground", className)} {...props} />;
}

/** Title and description, with room on the right for a `CardAction`. */
export function CardHeader({ className, ...props }: ComponentProps<"div">) {
  return <div data-slot="card-header" className={cn("grid grid-cols-[1fr_auto] items-start gap-x-3 gap-y-1 px-4", className)} {...props} />;
}

/** The card's name. A `<div>`: put an `<h3>` inside it when the card is a section of the page. */
export function CardTitle({ className, ...props }: ComponentProps<"div">) {
  return <div data-slot="card-title" className={cn("col-start-1 text-base leading-5 font-semibold", className)} {...props} />;
}

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

/** A button or menu in the top right corner of the header. */
export function CardAction({ className, ...props }: ComponentProps<"div">) {
  return <div data-slot="card-action" className={cn("col-start-2 row-span-2 row-start-1 self-start", className)} {...props} />;
}

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

export function CardFooter({ className, ...props }: ComponentProps<"div">) {
  return <div data-slot="card-footer" className={cn("flex items-center gap-2 px-4", className)} {...props} />;
}

Files and dependencies

Adds
components/ui/card.tsx
Packages
None
Brings along
Nothing

Changelog

  1. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor