cardContent
Replaces the built-in card template with a custom Svelte component. The wrapper element (selection state, drag affordances, data-id, CSS classes) stays intact - only the content inside it changes.
Usage
cardContent?: Component<{ card: KanbanCard; cardShape: CardShape }>;
The component receives two props:
| Field | Type | Description |
|---|---|---|
card | KanbanCard | Source card data object |
cardShape | CardShape | Current section visibility map from card |
Example
<script>
import { Kanban } from "@svar-ui/svelte-kanban";
import MyCard from "./MyCard.svelte";
</script>
<Kanban {cards} {columns} cardContent={MyCard} />
<!-- MyCard.svelte -->
<script>
const { card, cardShape } = $props();
</script>
<div class="my-card">
<strong>{card.label}</strong>
{#if card.owner}
<span>{card.owner}</span>
{/if}
</div>
The drag ghost renders the same component.
The component also replaces the built-in ⋯ card menu button. To keep the button, render CardMenuButton (props: card, optional css) inside the component:
<!-- MyCard.svelte -->
<script>
import { CardMenuButton } from "@svar-ui/svelte-kanban";
const { card, cardShape } = $props();
</script>
<div class="my-card">
<strong>{card.label}</strong>
{#if cardShape.menu}<CardMenuButton {card} />{/if}
</div>
Related
- Cards guide - card data shape and custom card body
- card - CardShape controlling section visibility
- cardCss - per-card CSS classes
- Card Menu -
CardActionMenuthat theCardMenuButtonopens