# Card

The one surface for every in-page card: white, a 1 px border, 8 px corners standing alone and 4 nested, 16 / 12 padding, never a shadow. A clickable card shades on hover and tints its border navy.

- Beta: ready to use; its API can still change in a minor release.
- Category: Layout & surfaces

```tsx
import { Card, CardButton, CardLabel, CardValue } from "@leap-crm/design-system";
```

## Best practices

- Do: Set `nested` on a card inside another bordered surface, like a card in a panel: its corners drop from 8 px to 4 px, smaller than its container's.
- Do: Use `CardButton` when the whole card opens something, so it is one focus stop with one name instead of a card holding a link.
- Do: Use one card per record or figure. Its 1 px border separates it from the page; no shadow or fill is needed.
- Don't: Give a card a shadow or a coloured fill. Put role or status colour in a dot, badge or thin border inside it.
- Don't: Nest a card inside a card more than one level deep. Use a list or a table for the inner rows.

## Keyboard

| Keys | What they do |
| --- | --- |
| Enter, Space | Presses a card that does something. |

## Related

- [Stat Card](./stat-card.md)
- [Guide Card](./guide-card.md)
- [Opportunity Card](./opportunity-card.md)
- [Note tile](./note-tile.md)

## Examples

What the examples import:

```tsx
import { useState } from "react";
import { Card, CardButton, CardLabel, CardValue } from "@leap-crm/design-system";
```

Scaffolding the examples call. It lives in the docs page, not in the library:

```tsx
const stages = [
  { id: "pipeline", label: "Pipeline value", value: "$184,250" },
  { id: "won", label: "Won this month", value: "$42,600" },
  { id: "open", label: "Open opportunities", value: "38" },
] as const;

function Selectable() {
  const [selected, setSelected] = useState<string>("pipeline");
  return (
    <div className="flex flex-wrap gap-3">
      {stages.map(stage => (
        <CardButton
          key={stage.id}
          selected={selected === stage.id}
          onClick={() => setSelected(stage.id)}
          className="w-50"
        >
          <CardLabel>{stage.label}</CardLabel>
          <CardValue>{stage.value}</CardValue>
        </CardButton>
      ))}
    </div>
  );
}
```

### Static

Standing alone (8 px corners) and nested in another surface (4 px).

```tsx
<div className="flex flex-wrap items-start gap-3">
  <Card className="w-50">
    <CardLabel>Pipeline value</CardLabel>
    <CardValue>$184,250</CardValue>
  </Card>
  <Card className="w-72 gap-3">
    <CardLabel>Nested</CardLabel>
    <Card nested>
      <CardLabel>Won this month</CardLabel>
      <CardValue>$42,600</CardValue>
    </Card>
  </Card>
</div>
```

### Clickable

Hover shades it and tints the border navy; the chosen card has a navy border (aria-pressed); Tab to see focus.

```tsx
<Selectable />
```

## Props

Card takes every prop of a <div>. CardButton takes ui-sdk's Button props: onClick, disabled and render (for a card that's a link).

### Card

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `nested` | `boolean` | `false` | Inside another surface, like a card in a panel: 4 px corners instead of 8. |

### CardButton

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `nested` | `boolean` | `false` | Inside another surface, like a card in a panel: 4 px corners instead of 8. |
| `selected` | `boolean` |  | Marks the card chosen among others, with a navy border. Sets aria-pressed. |
| `children` | `ReactNode` |  | What it shows inside. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### CardLabel

No props of its own.

### CardValue

No props of its own.
