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
<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} />Add-card footer & custom header
Loading interactive example…
View source
<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
| Name | Type | Default | Description |
|---|---|---|---|
columnsrequired | KanbanColumn[] | — | 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. |
columnHeader | Snippet<[column: KanbanColumn]> | — | Replace the default header row (dot, title, count). |
class | string | '' | Additional CSS classes on the horizontal scroller. |
card | Snippet<[card: KanbanCard, columnId: string]> | — | Custom card body; you still get drag handles via the outer dndItem wrapper. |
KanbanColumn
From phoundry-ui@0.4.21
| Name | Type | Default | Description |
|---|---|---|---|
idrequired | string | — | Unique column identifier. |
titlerequired | string | — | Column header text. |
cardsrequired | KanbanCard[] | — | Cards in this column. |
color | string | — | Accent color for the column header. |
KanbanCard
From phoundry-ui@0.4.21
| Name | Type | Default | Description |
|---|---|---|---|
idrequired | string | — | Unique card identifier. |
titlerequired | string | — | Card title text. |
description | string | — | Optional card description. |
labels | { text: string; color: string; }[] | — | Optional label tags with text and color. |
KanbanMoveEvent
From phoundry-ui@0.4.21
| Name | Type | Default | Description |
|---|---|---|---|
cardrequired | KanbanCard | — | The card being moved. |
fromColumnIdrequired | string | — | Source column ID. |
fromIndexrequired | number | — | Original index in source column. |
toColumnIdrequired | string | — | Target column ID. |
toIndexrequired | number | — | Target index in destination column. |
Usage tips
- The
onmovehandler receives the full move event - you’re responsible for updating column state immutably. - Use the
cardsnippet prop for custom card rendering (e.g. avatars, due dates, priority indicators). - Column
coloris rendered as a header accent - use brand or status colors to differentiate lanes. - Cards support
labelsfor lightweight categorization displayed as tags. DndGhostandDndIndicatorship 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.