Card

Elevated, filled, and outlined cards with 12dp corners.

M3: Cards

Glass Souls world tour
From your recent favorites
Live in your city on October 12. Presale opens Friday at 10 AM.

Installation

npx shadcn@latest add https://mountainview-ui.baltoon.jp/r/card.json

Requires the theme tokens — see Installation if this is your first component.

Source

import * as React from "react";
import { cva, type VariantProps } from "class-variance-authority";

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

/** M3 cards: elevated, filled, and outlined. 12dp corners. */
const cardVariants = cva("flex flex-col rounded-md text-on-surface", {
  variants: {
    variant: {
      elevated: "bg-surface-low shadow-[var(--shadow-elevation-1)]",
      filled: "bg-surface-highest",
      outlined: "bg-surface shadow-[inset_0_0_0_1px_var(--outline-variant)]",
    },
  },
  defaultVariants: { variant: "elevated" },
});

function Card({
  className,
  variant,
  ...props
}: React.ComponentProps<"div"> & VariantProps<typeof cardVariants>) {
  return (
    <div
      data-slot="card"
      className={cn(cardVariants({ variant }), className)}
      {...props}
    />
  );
}

function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-header"
      className={cn("flex flex-col gap-1 p-4", className)}
      {...props}
    />
  );
}

function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div data-slot="card-title" className={cn("text-title-m", className)} {...props} />
  );
}

function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-description"
      className={cn("text-body-m text-on-surface-variant", className)}
      {...props}
    />
  );
}

function CardContent({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      data-slot="card-content"
      className={cn("px-4 pb-2 text-body-m text-on-surface-variant", className)}
      {...props}
    />
  );
}

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

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