Skip to content
iv-ui v0.3.0

Card

since 0.1.0

A bordered surface for grouped content and actions.

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

Basic

A title, description, and body content.

Edge cache

Hit rate across the last 24 hours.

98.4% of requests were served from the nearest edge.

Source· svelte Show Hide
<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>
  • 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.

Header action

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

Deployments

The last three runs for this project.

Refreshed 0 times.

Source· svelte Show Hide
<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.

Open the runbook

Click anywhere on the card, or focus it and press Enter.

Opened 0 times.

Source· svelte Show Hide
<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.

Selected

Chosen in the current step.

Reverse-video border and cursor marker.

Hoverable

Hover is visual only.

No button role, no tab stop.

Disabled

Interaction is blocked.

Still readable.

Source· svelte Show Hide
<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>
import { Card } from '@elluzion/iv-ui';

Props

8 props · 1 events · 4 snippets
PropTypeDefaultDescription
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 booleanfalseAdds the hover treatment without making the card interactive.
selected booleanfalseRenders the selected treatment.
disabled booleanfalseDisables 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

EventHandler typeDescription
onclick(e: MouseEvent) => voidMakes the card interactive and called on activation.

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

Snippets

SnippetTypeDescription
childrenSnippetContent rendered inside the component.
actionSnippetSlot in the header, right of the title.
headerSnippetReplaces the default header.
footerSnippetContent rendered below the body.
KeysAction
TabMoves focus to an interactive card.
Enter / SpaceActivates 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.
Class 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
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records