Skip to content

KanbanBoard

Drag-and-drop kanban board with columns, cards, labels, and custom card rendering.

import { KanbanBoard } from "phoundry-ui";

Basic Board

Loading interactive example…

View source
basic-board.svelte
<script lang="ts">
import { KanbanBoard } from "phoundry-ui";
import type { KanbanColumn, KanbanMoveEvent } from "phoundry-ui";
let columns = $state<KanbanColumn[]>([
{
id: "todo",
title: "To Do",
color: "#6366f1",
cards: [
{
id: "c1",
title: "Design landing page",
description: "Create mockups for the new landing page",
labels: [{ text: "design", color: "#8b5cf6" }],
},
{
id: "c2",
title: "Set up CI/CD",
labels: [{ text: "devops", color: "#06b6d4" }],
},
{
id: "c3",
title: "Write API docs",
description: "Document REST endpoints",
labels: [{ text: "docs", color: "#f97316" }],
},
],
},
{
id: "progress",
title: "In Progress",
color: "#f59e0b",
cards: [
{
id: "c4",
title: "Implement auth flow",
description: "OAuth2 + session management",
labels: [{ text: "backend", color: "#ef4444" }],
},
{
id: "c5",
title: "Build component library",
labels: [{ text: "frontend", color: "#22c55e" }],
},
],
},
{
id: "done",
title: "Done",
color: "#22c55e",
cards: [
{
id: "c6",
title: "Project setup",
labels: [{ text: "devops", color: "#06b6d4" }],
},
],
},
]);
function handleMove(event: KanbanMoveEvent) {
const newColumns = columns.map((col) => ({
...col,
cards: col.cards.filter((c) => c.id !== event.card.id),
}));
const targetCol = newColumns.find((c) => c.id === event.toColumnId);
if (targetCol) {
targetCol.cards.splice(event.toIndex, 0, event.card);
}
columns = newColumns;
}
</script>
<KanbanBoard {columns} onmove={handleMove} />

Loading interactive example…

View source
add-card-footer-custom-header.svelte
<script lang="ts">
import { KanbanBoard } from "phoundry-ui";
import type { KanbanColumn, KanbanMoveEvent } from "phoundry-ui";
let columns = $state<KanbanColumn[]>([
{
id: "todo",
title: "To Do",
color: "#6366f1",
cards: [
{
id: "c1",
title: "Design landing page",
description: "Create mockups for the new landing page",
labels: [{ text: "design", color: "#8b5cf6" }],
},
{
id: "c2",
title: "Set up CI/CD",
labels: [{ text: "devops", color: "#06b6d4" }],
},
{
id: "c3",
title: "Write API docs",
description: "Document REST endpoints",
labels: [{ text: "docs", color: "#f97316" }],
},
],
},
{
id: "progress",
title: "In Progress",
color: "#f59e0b",
cards: [
{
id: "c4",
title: "Implement auth flow",
description: "OAuth2 + session management",
labels: [{ text: "backend", color: "#ef4444" }],
},
{
id: "c5",
title: "Build component library",
labels: [{ text: "frontend", color: "#22c55e" }],
},
],
},
{
id: "done",
title: "Done",
color: "#22c55e",
cards: [
{
id: "c6",
title: "Project setup",
labels: [{ text: "devops", color: "#06b6d4" }],
},
],
},
]);
let lastAddColumn = $state("");
function handleMove(event: KanbanMoveEvent) {
const newColumns = columns.map((col) => ({
...col,
cards: col.cards.filter((c) => c.id !== event.card.id),
}));
const targetCol = newColumns.find((c) => c.id === event.toColumnId);
if (targetCol) {
targetCol.cards.splice(event.toIndex, 0, event.card);
}
columns = newColumns;
}
</script>
{#snippet columnHeader(column: KanbanColumn)}
<div
class="flex items-center justify-between gap-2 border-b border-border-muted px-3 py-2"
>
<span class="truncate text-xs font-semibold text-txt-primary"
>{column.title}</span
>
<span
class="shrink-0 rounded-full bg-surface-raised px-1.5 py-0.5 text-[10px] text-txt-tertiary"
>{column.cards.length}</span
>
</div>
{/snippet}
<p class="mb-2 text-xs text-txt-secondary">
<code>onadd</code> is separate from the optional header snippet - this demo uses
both for illustration.
</p>
<KanbanBoard
{columns}
onmove={handleMove}
onadd={(id) => (lastAddColumn = id)}
{columnHeader}
/>
{#if lastAddColumn}
<p class="mt-2 text-[11px] text-txt-tertiary">
Last add click: <code>{lastAddColumn}</code>
</p>
{/if}

API

From phoundry-ui@0.4.21

NameTypeDefaultDescription
columnsrequiredKanbanColumn[]—Array of columns with their cards.
onmove(event: KanbanMoveEvent) => void—Called after a reorder or cross-column drop. Omit only for read-only previews.
onadd(columnId: string) => void—When set, each column shows an “Add card” footer that passes its column id.
columnHeaderSnippet<[column: KanbanColumn]>—Replace the default header row (dot, title, count).
classstring''Additional CSS classes on the horizontal scroller.
cardSnippet<[card: KanbanCard, columnId: string]>—Custom card body; you still get drag handles via the outer dndItem wrapper.

KanbanColumn

From phoundry-ui@0.4.21

NameTypeDefaultDescription
idrequiredstring—Unique column identifier.
titlerequiredstring—Column header text.
cardsrequiredKanbanCard[]—Cards in this column.
colorstring—Accent color for the column header.

KanbanCard

From phoundry-ui@0.4.21

NameTypeDefaultDescription
idrequiredstring—Unique card identifier.
titlerequiredstring—Card title text.
descriptionstring—Optional card description.
labels{ text: string; color: string; }[]—Optional label tags with text and color.

KanbanMoveEvent

From phoundry-ui@0.4.21

NameTypeDefaultDescription
cardrequiredKanbanCard—The card being moved.
fromColumnIdrequiredstring—Source column ID.
fromIndexrequirednumber—Original index in source column.
toColumnIdrequiredstring—Target column ID.
toIndexrequirednumber—Target index in destination column.

Usage tips

  • The onmove handler receives the full move event - you’re responsible for updating column state immutably.
  • Use the card snippet prop for custom card rendering (e.g. avatars, due dates, priority indicators).
  • Column color is rendered as a header accent - use brand or status colors to differentiate lanes.
  • Cards support labels for lightweight categorization displayed as tags.
  • DndGhost and DndIndicator ship inside the component - import bundled styles so drag visuals match other DnD surfaces.

CSS styling

.ph-kanban-board is the stable identification hook for KanbanBoard. Part selectors and --_ph-* properties are internal. Component CSS is scoped and unlayered; Consumer classes remain additive and utility overrides may lose precedence.

Column and card styling is scoped locally. Consumer-provided card and label colors remain runtime values. Drag-and-drop callbacks are unchanged.

Keep the shared component stylesheet and a named Theme imported. Decorative motion respects reduced-motion preferences.

Documentation is licensed under CC BY 4.0. Phoundry names and marks remain reserved.