# Card

> A surface for grouping content, with outline, elevated and filled variants, padding sizes, an icon tile, a title and a description.

Source: https://docs.cherry.al/components/card

> For the complete documentation index, see [llms.txt](https://docs.cherry.al/llms.txt).

# Card

<Preview bleed>
<iframe className="light-only" src="https://v2.cherry.al/preview/card?theme=light" title="Card preview" loading="lazy" style={{ width: "100%", height: "560px" }} />
<iframe className="dark-only" src="https://v2.cherry.al/preview/card?theme=dark" title="Card preview" loading="lazy" style={{ width: "100%", height: "560px" }} />

```tsx
import { Card, CardDescription, CardIcon, CardTitle } from "@cherry-design-system/react";
import { Layers } from "lucide-react";

export function Feature() {
  return (
    <Card variant="outline">
      <CardIcon>
        <Layers />
      </CardIcon>
      <CardTitle level={3}>Token-driven theming</CardTitle>
      <CardDescription>Swap brands and modes from one set of variables.</CardDescription>
    </Card>
  );
}
```
</Preview>

Card is a bordered or filled surface that groups related content. Compose it with `CardIcon`, `CardTitle` and `CardDescription`. For a metric tile use [StatCard](/components/stat-card) instead.

## Examples

### Variants

`outline` has a border, `elevated` adds a shadow, `filled` uses a subtle fill.

```tsx
import { Card } from "@cherry-design-system/react";

export function Variants() {
  return (
    <>
      <Card variant="outline">Outline</Card>
      <Card variant="elevated">Elevated</Card>
      <Card variant="filled">Filled</Card>
    </>
  );
}
```

### Padding

`padding` is `"md"` (20px) by default. Use `"none"` when the content brings its own spacing, such as an edge-to-edge image or a table.

```tsx
import { Card } from "@cherry-design-system/react";

export function Paddings() {
  return (
    <>
      <Card padding="sm">Small</Card>
      <Card padding="lg">Large</Card>
      <Card padding="none">
        <img src="/cover.jpg" alt="" />
      </Card>
    </>
  );
}
```

### Interactive card

`interactive` lifts the card on hover. Use it when the card holds a single link or button that names it.

```tsx
import { Card, CardDescription, CardTitle } from "@cherry-design-system/react";

export function DocsCard() {
  return (
    <Card interactive>
      <CardTitle level={3}>
        <a href="/installation">Installation</a>
      </CardTitle>
      <CardDescription>Install the package and import the styles.</CardDescription>
    </Card>
  );
}
```

## Properties

### Card

<Field value="variant" type='"outline" | "elevated" | "filled"'>
  `outline` (border), `elevated` (border and shadow), `filled` (subtle fill). Defaults to `"outline"`.
</Field>

<Field value="padding" type='"sm" | "md" | "lg" | "none"'>
  Inner padding. Defaults to `"md"` (20px).
</Field>

<Field value="interactive" type="boolean">
  Lifts on hover, for cards that hold a single link or button.
</Field>

Card renders a `<div>`, forwards its ref and passes every other `<div>` attribute through.

### CardIcon

<Field value="children" type="ReactNode" required>
  The icon, for example a lucide element.
</Field>

CardIcon renders a `<span>` with `aria-hidden="true"`, forwards its ref and passes other `<span>` attributes through.

### CardTitle

<Field value="level" type="2 | 3 | 4 | 5 | 6">
  Heading level. Defaults to `3`.
</Field>

CardTitle renders an `<h2>` to `<h6>` heading, forwards its ref and passes other heading attributes through.

### CardDescription

CardDescription has no props of its own. It renders a `<p>`, forwards its ref and passes `<p>` attributes through.

All parts are safe in Server Components.

## Styling

| Hook | Values |
| --- | --- |
| Class | `cherry-card` |
| `data-variant` | `outline`, `elevated`, `filled` |
| `data-padding` | `none`, `sm`, `md`, `lg` |
| States | `data-interactive`, `:hover`, `:focus-within` |
| Parts | `cherry-card__icon`, `cherry-card__title`, `cherry-card__description` |

The surface reads `--cherry-bg-elevated`, `--cherry-bg-subtle`, `--cherry-border-default`, `--cherry-radius-lg` and the `--cherry-elevation-*` shadows.

## Accessibility

Card has no role of its own. Give it a `CardTitle` at the right `level` so the page outline stays correct. An `interactive` card needs a single link or button inside that names it. `CardIcon` is decorative and hidden from assistive tech.

<Button href="https://github.com/cherry-design-system/react/tree/main/src/components/card" icon="code" iconPosition="left">
  View Source
</Button>
