---
title: "Card"
description: "A bordered surface for grouped content and actions."
category: "Layout & Navigation"
slug: card
url: /components/card
since: "0.1.0"
status: "stable"
---

# Card

A bordered surface for grouped content and actions.

## Import

```svelte
import { Card } from '@elluzion/iv-ui';
```

## Preview

A title, description, and body content.

```svelte
<script lang="ts">
	import { Card } from '@elluzion/iv-ui';
</script>

<Card title="Edge cache" description="Hit rate across the last 24 hours.">
	<p class="body">98.4% of requests were served from the nearest edge.</p>
</Card>

<style>
	.body {
		margin: 0;
		font-family: var(--iv_font-mono);
		font-size: var(--iv_text-body);
		color: var(--iv_foreground-dim);
	}
</style>
```

## Usage

- `title`, `description`, and `action` build the standard header; `header` replaces it.
- Providing `onclick` makes the whole card a keyboard-reachable button.
- `footer` renders below the body; `padding="none"` lets lists manage their own spacing.

## Examples

### Header action

`action` places a control at the trailing edge of the header.

```svelte
<script lang="ts">
	import { Button, Card } from '@elluzion/iv-ui';

	let refreshed = $state(0);
</script>

<Card title="Deployments" description="The last three runs for this project.">
	{#snippet action()}
		<Button size="sm" variant="ghost" onclick={() => refreshed++}>Refresh</Button>
	{/snippet}
	<p class="body">Refreshed {refreshed} times.</p>
</Card>

<style>
	.body {
		margin: 0;
		font-family: var(--iv_font-mono);
		font-size: var(--iv_text-body);
		color: var(--iv_foreground-dim);
	}
</style>
```

### Interactive

`onclick` adds the button role, tab stop, and keyboard activation.

```svelte
<script lang="ts">
	import { Card } from '@elluzion/iv-ui';

	let opened = $state(0);
</script>

<Card
	title="Open the runbook"
	description="Click anywhere on the card, or focus it and press Enter."
	hoverable
	onclick={() => opened++}
>
	<p class="body">Opened {opened} times.</p>
</Card>

<style>
	.body {
		margin: 0;
		font-family: var(--iv_font-mono);
		font-size: var(--iv_text-body);
		color: var(--iv_foreground-dim);
	}
</style>
```

### States

Selected, hoverable, and disabled treatments.

```svelte
<script lang="ts">
	import { Card } from '@elluzion/iv-ui';
</script>

<div class="grid">
	<Card title="Selected" description="Chosen in the current step." selected>
		<p class="body">Reverse-video border and cursor marker.</p>
	</Card>
	<Card title="Hoverable" description="Hover is visual only." hoverable>
		<p class="body">No button role, no tab stop.</p>
	</Card>
	<Card title="Disabled" description="Interaction is blocked." disabled onclick={() => {}}>
		<p class="body">Still readable.</p>
	</Card>
</div>

<style>
	.grid {
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
		gap: var(--iv_spacing-md);
		width: 100%;
	}

	.body {
		margin: 0;
		font-family: var(--iv_font-mono);
		font-size: var(--iv_text-sm);
		color: var(--iv_foreground-dim);
	}
</style>
```

### Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `string` | `''` | Title text. |
| `description` | `string` | `''` | Supporting text. |
| `padding` | `'sm' \| 'md' \| 'lg' \| 'none'` | `'md'` | Inner padding. `none` is useful for lists that manage their own spacing. |
| `radius` | `'md' \| 'lg'` | `'md'` | Corner radius step. |
| `hoverable` | `boolean` | `false` | Adds the hover treatment without making the card interactive. |
| `selected` | `boolean` | `false` | Renders the selected treatment. |
| `disabled` | `boolean` | `false` | Disables interaction and applies the disabled treatment. |
| `className` | `string` | `''` | Extra classes merged onto the root element. |

`class`, `id`, `style`, `aria-*`, and `data-*` are forwarded through rest props.

### Events

| Event | Handler type | Description |
| --- | --- | --- |
| `click` | `(e: MouseEvent) => void` | Makes the card interactive and called on activation. |

The legacy `on:name` form is accepted for every event.

### Snippets

| Snippet | Type | Description |
| --- | --- | --- |
| `children` | `Snippet` | Content rendered inside the component. |
| `action` | `Snippet` | Slot in the header, right of the title. |
| `header` | `Snippet` | Replaces the default header. |
| `footer` | `Snippet` | Content rendered below the body. |

### Tokens used

`--iv_accent` · `--iv_accent-surface` · `--iv_border` · `--iv_border-focus` · `--iv_border-hover` · `--iv_card-pad-x` · `--iv_card-pad-x-lg` · `--iv_card-pad-x-sm` · `--iv_card-pad-y` · `--iv_card-pad-y-lg` · `--iv_card-pad-y-sm` · `--iv_cursor` · `--iv_disabled-opacity` · `--iv_ease-in-out` · `--iv_font-sans` · `--iv_font-ui` · `--iv_foreground` · `--iv_foreground-dim` · `--iv_hazard-stripe` · `--iv_radius` · `--iv_radius-lg` · `--iv_ring` · `--iv_ring-width` · `--iv_spacing-lg` · `--iv_spacing-sm` · `--iv_spacing-xs` · `--iv_surface-raised` · `--iv_text-base` · `--iv_text-label` · `--iv_transition-base`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-action` · `.iv-body` · `.iv-card` · `.iv-clickable` · `.iv-description` · `.iv-disabled` · `.iv-footer` · `.iv-header` · `.iv-header-text` · `.iv-hoverable` · `.iv-pad-lg` · `.iv-pad-none` · `.iv-pad-sm` · `.iv-radius-lg` · `.iv-selected` · `.iv-title`

## Accessibility

| Keys | Action |
| --- | --- |
| `Tab` | Moves focus to an interactive card. |
| `Enter / Space` | Activates an interactive card. |

- An interactive card gets `role="button"`, `tabindex="0"`, and `aria-disabled` when disabled.
- Do not place buttons or links inside a card that is itself clickable; move them to `action` or `footer` and keep the card static.
- `hoverable` changes only the visual treatment and does not make the card interactive.

## Related

- [Article](/components/article.md)
- [Accordion](/components/accordion.md)
- [EmptyState](/components/empty-state.md)
- [Separator](/components/separator.md)