Card

A surface that groups related content: a header with a title, a description and an action, above the content that belongs to them.

Title
Description
Content goes here.
import { Button } from "@produkto/ui/Button";
import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@produkto/ui/Card";

const Example = () => (
  <Card className="w-full max-w-sm">
    <CardHeader>
      <CardTitle>Title</CardTitle>
      <CardDescription>Description</CardDescription>
      <CardAction>
        <Button>Button</Button>
      </CardAction>
    </CardHeader>
    <CardContent>Content goes here.</CardContent>
  </Card>
);

export default Example;

Usage

import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@produkto/ui/Card";
<Card>
  <CardHeader>
    <CardTitle>Title</CardTitle>
    <CardDescription>Description</CardDescription>
    <CardAction>Button</CardAction>
  </CardHeader>
  <CardContent>
    <p>Content goes here.</p>
  </CardContent>
  <CardFooter>
    <p>Description</p>
  </CardFooter>
</Card>

Examples

Appearances

appearance paints the card on the kit's one scale: solid, the default, soft on the grey wash, outline with only its line, and transparent with neither.

Solid
Description
Soft
Description
Outline
Description
Transparent
Description
import {
  Card,
  CardDescription,
  CardHeader,
  CardTitle,
  type CardAppearance,
} from "@produkto/ui/Card";

const appearances: { appearance: CardAppearance; label: string }[] = [
  { appearance: "solid", label: "Solid" },
  { appearance: "soft", label: "Soft" },
  { appearance: "outline", label: "Outline" },
  { appearance: "transparent", label: "Transparent" },
];

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    {appearances.map((item) => (
      <Card appearance={item.appearance} key={item.appearance}>
        <CardHeader>
          <CardTitle>{item.label}</CardTitle>
          <CardDescription>Description</CardDescription>
        </CardHeader>
      </Card>
    ))}
  </div>
);

export default Example;

Sizes

size sets the padding and the gaps, sm 12px, base 16px (the default) or lg 20px, and steps the title and the description down with sm and up with lg.

Small
Description
Base
Description
Large
Description
import {
  Card,
  CardDescription,
  CardHeader,
  CardTitle,
  type CardSize,
} from "@produkto/ui/Card";

const sizes: { size: CardSize; label: string }[] = [
  { size: "sm", label: "Small" },
  { size: "base", label: "Base" },
  { size: "lg", label: "Large" },
];

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    {sizes.map((item) => (
      <Card key={item.size} size={item.size}>
        <CardHeader>
          <CardTitle>{item.label}</CardTitle>
          <CardDescription>Description</CardDescription>
        </CardHeader>
      </Card>
    ))}
  </div>
);

export default Example;

Border radius

borderRadius sets the corners on the kit's one scale: none, xs 4px, sm 6px, base 8px (the default), lg 12px or xl 16px, a CardMedia at its edge following them.

none
Description
xs
Description
sm
Description
base
Description
lg
Description
xl
Description
import {
  Card,
  CardDescription,
  CardHeader,
  CardTitle,
  type CardBorderRadius,
} from "@produkto/ui/Card";

const radii: CardBorderRadius[] = ["none", "xs", "sm", "base", "lg", "xl"];

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    {radii.map((borderRadius) => (
      <Card key={borderRadius} borderRadius={borderRadius}>
        <CardHeader>
          <CardTitle>{borderRadius}</CardTitle>
          <CardDescription>Description</CardDescription>
        </CardHeader>
      </Card>
    ))}
  </div>
);

export default Example;

Overflow

overflow hidden, the default, cuts what runs past the card's edge, and visible lets it out, as a chart's tooltip needs.

Hidden
Content goes here.
Visible
Content goes here.
import {
  Card,
  CardContent,
  CardHeader,
  CardTitle,
  type CardOverflow,
} from "@produkto/ui/Card";

const overflows: { overflow: CardOverflow; label: string }[] = [
  { overflow: "hidden", label: "Hidden" },
  { overflow: "visible", label: "Visible" },
];

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    {overflows.map((item) => (
      <Card key={item.overflow} overflow={item.overflow}>
        <CardHeader>
          <CardTitle>{item.label}</CardTitle>
        </CardHeader>
        <CardContent>
          <div className="-me-12 rounded-lg bg-muted p-2">
            Content goes here.
          </div>
        </CardContent>
      </Card>
    ))}
  </div>
);

export default Example;

Text

text on CardTitle sets the title's type: heading, the default, then label, body and description for quieter titles such as a dashboard card's.

Heading
Label
Body
Description
import {
  Card,
  CardHeader,
  CardTitle,
  type CardTitleText,
} from "@produkto/ui/Card";

const texts: { text: CardTitleText; label: string }[] = [
  { text: "heading", label: "Heading" },
  { text: "label", label: "Label" },
  { text: "body", label: "Body" },
  { text: "description", label: "Description" },
];

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    {texts.map((item) => (
      <Card key={item.text}>
        <CardHeader>
          <CardTitle text={item.text}>{item.label}</CardTitle>
        </CardHeader>
      </Card>
    ))}
  </div>
);

export default Example;

Truncate

truncate on CardTitle or CardDescription keeps it on one line, cut with an ellipsis, where by default it wraps.

Content goes here. Content goes here. Content goes here.
Content goes here. Content goes here. Content goes here.
Content goes here. Content goes here. Content goes here.
Content goes here. Content goes here. Content goes here.
import {
  Card,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@produkto/ui/Card";

const words = "Content goes here. Content goes here. Content goes here.";

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    <Card>
      <CardHeader>
        <CardTitle>{words}</CardTitle>
        <CardDescription>{words}</CardDescription>
      </CardHeader>
    </Card>
    <Card>
      <CardHeader>
        <CardTitle truncate>{words}</CardTitle>
        <CardDescription truncate>{words}</CardDescription>
      </CardHeader>
    </Card>
  </div>
);

export default Example;

Disabled

disabled fades the card to half and puts it out of reach of the pointer, the keyboard and screen readers, beside one as it is by default.

Title
Description
Title
Description
import {
  Card,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@produkto/ui/Card";

const Example = () => (
  <div className="flex w-full max-w-sm flex-col gap-4">
    <Card>
      <CardHeader>
        <CardTitle>Title</CardTitle>
        <CardDescription>Description</CardDescription>
      </CardHeader>
    </Card>
    <Card disabled>
      <CardHeader>
        <CardTitle>Title</CardTitle>
        <CardDescription>Description</CardDescription>
      </CardHeader>
    </Card>
  </div>
);

export default Example;

API Reference

Card

CardProps · components/Card/Card.types.ts
PropTypeDefault
appearanceCardAppearance"solid" | "soft" | "outline" | "transparent""solid"
sizeCardSize"sm" | "base" | "lg""base"
borderRadiusCardBorderRadius"none" | "xs" | "sm" | "base" | "lg" | "xl""base"
overflowCardOverflow"hidden" | "visible""hidden"
disabledbooleanfalse

CardHeader

CardHeaderProps · takes the props of <div>

CardTitle

CardTitleProps · also takes the props of <div>
PropTypeDefault
truncateboolean-
textCardTitleText"heading" | "label" | "body" | "description""heading"

CardDescription

CardDescriptionProps · also takes the props of <div>
PropTypeDefault
truncateboolean-

CardAction

CardActionProps · takes the props of <div>

CardMedia

CardMediaProps · takes the props of <div>

CardContent

CardContentProps · takes the props of <div>

CardFooter

CardFooterProps · takes the props of <div>

It also takes the props of <div>.