# Card

A surface that groups the content of one thing, with an optional header and footer.

A surface that groups one thing's content: a deploy, a plan, a pull request. White surface on the hairline ring. Elevation chooses the shadow stack; header, body and footer are optional parts. A long title wraps and never pushes header actions out; footer actions wrap.

Kind: component · Category: Display · Status: stable · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add card
```

It writes the folder `card/` into the project's ui folder (`index.ts`, `card.tsx`, `Card.vue`, `Card.svelte`, `card.recipe.ts`). First time: [Installation](/installation.md).

## Usage

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

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

```svelte
import { Card } from "$lib/components/ui/card";
```

## Parts

In the DOM the root carries `data-slot="card"` and each part `data-slot="card-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `div` | `card` |  |  |
| `header` | `div` | `card-header` | optional |  |
| `title` | `h3` | `card-title` | optional |  |
| `description` | `p` | `card-description` | optional |  |
| `body` | `div` | `card-body` | optional |  |
| `footer` | `div` | `card-footer` | optional |  |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `elevation` | `"hairline" \| "card" \| "raised" \| "overlay"` | `"card"` |  |
| `inset` | `boolean` | `false` | Inset (recessed) background instead of surface. |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Slots

| Slot | Content |
| --- | --- |
| `default` | Content |
| `header` | Header row |
| `footer` | Footer row |

## Keyboard and accessibility

Notes:

- A card is a plain container. Give it a heading (the title part is an h3 by default; pick the level that fits the page).
- It is not interactive; put buttons or links inside it rather than making the whole card clickable.

## Tokens

`color.surface`, `color.inset`, `color.ink`, `color.ink-2`, `color.line`, `shadow.hairline`, `shadow.card`, `shadow.raised`, `shadow.overlay`, `radius.card`, `radius.window`, `text.xs`, `text.sm`

## Examples

### Production deploy

React · `production-deploy.tsx`

```tsx
import { Button } from "@/components/ui/button";
import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { StatusPill } from "@/components/ui/status-pill";

export default function ProductionDeploy() {
  return (
    <Card className="w-80 max-w-full">
      <CardHeader>
        <div>
          <CardTitle>web-app to Production</CardTitle>
          <CardDescription>dpl_7f3a9c · main · built in 48s</CardDescription>
        </div>
        <StatusPill tone="green" className="ms-auto">Ready</StatusPill>
      </CardHeader>
      <CardFooter>
        <Button variant="primary" size="sm">Visit</Button>
        <Button variant="ghost" size="sm">View logs</Button>
      </CardFooter>
    </Card>
  );
}
```

Vue · `production-deploy.vue`

```vue
<script setup lang="ts">
import { Button } from "@/components/ui/button";
import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { StatusPill } from "@/components/ui/status-pill";
</script>

<template>
  <Card class="w-80 max-w-full">
    <CardHeader>
      <div>
        <CardTitle>web-app to Production</CardTitle>
        <CardDescription>dpl_7f3a9c · main · built in 48s</CardDescription>
      </div>
      <StatusPill tone="green" class="ms-auto">Ready</StatusPill>
    </CardHeader>
    <CardFooter>
      <Button variant="primary" size="sm">Visit</Button>
      <Button variant="ghost" size="sm">View logs</Button>
    </CardFooter>
  </Card>
</template>
```

Svelte · `production-deploy.svelte`

```svelte
<script lang="ts">
  import { Button } from "$lib/components/ui/button";
  import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "$lib/components/ui/card";
  import { StatusPill } from "$lib/components/ui/status-pill";
</script>

<Card class="w-80 max-w-full">
  <CardHeader>
    <div>
      <CardTitle>web-app to Production</CardTitle>
      <CardDescription>dpl_7f3a9c · main · built in 48s</CardDescription>
    </div>
    <StatusPill tone="green" class="ms-auto">Ready</StatusPill>
  </CardHeader>
  <CardFooter>
    <Button variant="primary" size="sm">Visit</Button>
    <Button variant="ghost" size="sm">View logs</Button>
  </CardFooter>
</Card>
```

### Plan and usage

React · `plan-and-usage.tsx`

```tsx
import { Button } from "@/components/ui/button";
import { Card, CardBody, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { TextRow } from "@/components/ui/text-row";

const usage = [
  { label: "Seats", value: "12", meta: "of 20" },
  { label: "Build minutes", value: "4,120", meta: "of 6,000" },
  { label: "Bandwidth", value: "182 GB", meta: "of 1 TB" },
];

export default function PlanAndUsage() {
  return (
    <Card className="w-80 max-w-full">
      <CardHeader>
        <div>
          <CardTitle>Team plan</CardTitle>
          <CardDescription>$240.00 a month · renews Dec 1, 2026</CardDescription>
        </div>
      </CardHeader>
      <CardBody>
        {usage.map((row) => (
          <TextRow key={row.label} label={row.label} value={row.value} meta={row.meta} />
        ))}
      </CardBody>
      <CardFooter>
        <Button variant="primary" size="sm">Upgrade to Business</Button>
        <Button variant="ghost" size="sm">Compare plans</Button>
      </CardFooter>
    </Card>
  );
}
```

Vue · `plan-and-usage.vue`

```vue
<script setup lang="ts">
import { Button } from "@/components/ui/button";
import { Card, CardBody, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { TextRow } from "@/components/ui/text-row";

const usage = [
  { label: "Seats", value: "12", meta: "of 20" },
  { label: "Build minutes", value: "4,120", meta: "of 6,000" },
  { label: "Bandwidth", value: "182 GB", meta: "of 1 TB" },
];
</script>

<template>
  <Card class="w-80 max-w-full">
    <CardHeader>
      <div>
        <CardTitle>Team plan</CardTitle>
        <CardDescription>$240.00 a month · renews Dec 1, 2026</CardDescription>
      </div>
    </CardHeader>
    <CardBody>
      <TextRow v-for="row in usage" :key="row.label" :label="row.label" :value="row.value" :meta="row.meta" />
    </CardBody>
    <CardFooter>
      <Button variant="primary" size="sm">Upgrade to Business</Button>
      <Button variant="ghost" size="sm">Compare plans</Button>
    </CardFooter>
  </Card>
</template>
```

Svelte · `plan-and-usage.svelte`

```svelte
<script lang="ts">
  import { Button } from "$lib/components/ui/button";
  import { Card, CardBody, CardDescription, CardFooter, CardHeader, CardTitle } from "$lib/components/ui/card";
  import { TextRow } from "$lib/components/ui/text-row";

  const usage = [
    { label: "Seats", value: "12", meta: "of 20" },
    { label: "Build minutes", value: "4,120", meta: "of 6,000" },
    { label: "Bandwidth", value: "182 GB", meta: "of 1 TB" },
  ];
</script>

<Card class="w-80 max-w-full">
  <CardHeader>
    <div>
      <CardTitle>Team plan</CardTitle>
      <CardDescription>$240.00 a month · renews Dec 1, 2026</CardDescription>
    </div>
  </CardHeader>
  <CardBody>
    {#each usage as row (row.label)}
      <TextRow label={row.label} value={row.value} meta={row.meta} />
    {/each}
  </CardBody>
  <CardFooter>
    <Button variant="primary" size="sm">Upgrade to Business</Button>
    <Button variant="ghost" size="sm">Compare plans</Button>
  </CardFooter>
</Card>
```

### Delete project in settings

React · `danger-zone.tsx`

```tsx
import { Button } from "@/components/ui/button";
import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";

/* hairline: a section among the settings of a page, no shadow */
export default function DangerZone() {
  return (
    <Card elevation="hairline" className="w-96 max-w-full">
      <CardHeader>
        <div>
          <CardTitle>Delete project</CardTitle>
          <CardDescription>Removes billing-api, its 214 deploys and its two domains. This cannot be undone.</CardDescription>
        </div>
      </CardHeader>
      <CardFooter>
        <Button variant="danger" size="sm">Delete billing-api</Button>
      </CardFooter>
    </Card>
  );
}
```

Vue · `danger-zone.vue`

```vue
<script setup lang="ts">
import { Button } from "@/components/ui/button";
import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
</script>

<!-- hairline: a section among the settings of a page, no shadow -->
<template>
  <Card elevation="hairline" class="w-96 max-w-full">
    <CardHeader>
      <div>
        <CardTitle>Delete project</CardTitle>
        <CardDescription>Removes billing-api, its 214 deploys and its two domains. This cannot be undone.</CardDescription>
      </div>
    </CardHeader>
    <CardFooter>
      <Button variant="danger" size="sm">Delete billing-api</Button>
    </CardFooter>
  </Card>
</template>
```

Svelte · `danger-zone.svelte`

```svelte
<script lang="ts">
  import { Button } from "$lib/components/ui/button";
  import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "$lib/components/ui/card";
</script>

<!-- hairline: a section among the settings of a page, no shadow -->
<Card elevation="hairline" class="w-96 max-w-full">
  <CardHeader>
    <div>
      <CardTitle>Delete project</CardTitle>
      <CardDescription>Removes billing-api, its 214 deploys and its two domains. This cannot be undone.</CardDescription>
    </div>
  </CardHeader>
  <CardFooter>
    <Button variant="danger" size="sm">Delete billing-api</Button>
  </CardFooter>
</Card>
```

### No deploys yet

React · `no-deploys-yet.tsx`

```tsx
import { Button } from "@/components/ui/button";
import { Card, CardBody } from "@/components/ui/card";

/* inset: recessed into the page, for a placeholder that waits for content */
export default function NoDeploysYet() {
  return (
    <Card elevation="hairline" inset className="w-80 max-w-full">
      <CardBody className="flex flex-col items-center gap-3 py-6 text-center">
        <div>
          <p className="font-medium text-ink">No deploys yet</p>
          <p className="text-ink-2">docs-site has not been deployed. Push to main or deploy it now.</p>
        </div>
        <Button size="sm">Deploy now</Button>
      </CardBody>
    </Card>
  );
}
```

Vue · `no-deploys-yet.vue`

```vue
<script setup lang="ts">
import { Button } from "@/components/ui/button";
import { Card, CardBody } from "@/components/ui/card";
</script>

<!-- inset: recessed into the page, for a placeholder that waits for content -->
<template>
  <Card elevation="hairline" inset class="w-80 max-w-full">
    <CardBody class="flex flex-col items-center gap-3 py-6 text-center">
      <div>
        <p class="font-medium text-ink">No deploys yet</p>
        <p class="text-ink-2">docs-site has not been deployed. Push to main or deploy it now.</p>
      </div>
      <Button size="sm">Deploy now</Button>
    </CardBody>
  </Card>
</template>
```

Svelte · `no-deploys-yet.svelte`

```svelte
<script lang="ts">
  import { Button } from "$lib/components/ui/button";
  import { Card, CardBody } from "$lib/components/ui/card";
</script>

<!-- inset: recessed into the page, for a placeholder that waits for content -->
<Card elevation="hairline" inset class="w-80 max-w-full">
  <CardBody class="flex flex-col items-center gap-3 py-6 text-center">
    <div>
      <p class="font-medium text-ink">No deploys yet</p>
      <p class="text-ink-2">docs-site has not been deployed. Push to main or deploy it now.</p>
    </div>
    <Button size="sm">Deploy now</Button>
  </CardBody>
</Card>
```

## Recipe

`card.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";

/* card — white surface on the hairline ring. Elevation picks the shadow stack; overlay also takes
 * the window radius. The header wraps: whatever holds the title may shrink and keeps at least
 * 10rem beside the actions, which drop to a line of their own rather than squeeze the title.
 * No motion. Each part is its own adapter component (CardHeader, CardTitle …),
 * marked data-slot="card-<part>"; the first slot is `base`. */

export const card = tv({
  slots: {
    base: "flex flex-col min-w-0 rounded-card bg-surface text-ink shadow-card overflow-clip",
    header: [
      "flex flex-wrap items-center gap-2 py-2.5 px-3 border-b border-solid border-b-line",
      "*:min-w-0 [&>[data-slot=card-title]]:flex-[1_1_10rem] [&>:has(>[data-slot=card-title])]:flex-[1_1_10rem]",
    ],
    title: "m-0 text-sm font-medium text-ink wrap-anywhere [unicode-bidi:plaintext] [text-align:match-parent]",
    description: "m-0 text-xs text-ink-2 wrap-anywhere [unicode-bidi:plaintext] [text-align:match-parent]",
    body: "p-3 wrap-break-word",
    footer: "flex flex-wrap items-center gap-2 p-2.5 border-t border-solid border-t-line bg-inset",
  },
  variants: {
    elevation: {
      hairline: { base: "shadow-hairline" },
      card: { base: "shadow-card" },
      raised: { base: "shadow-raised" },
      overlay: { base: "shadow-overlay rounded-window" },
    },
    inset: { true: { base: "bg-inset" } },
  },
  defaultVariants: { elevation: "card" },
});

export type CardRecipeProps = VariantProps<typeof card>;
```
