Kanban Board
Multi-column task board for moving cards between workflow stages with keyboard and drag-and-drop support.
To do
2In progress
1Done
1Keyboard
- SpaceEnter
- Pick up or drop a card
- ↑↓
- Move card within column
- ←→
- Move card across columns
- Escape
- Cancel the move
On this page
Installation
The CLI also installs the npm packages and registry items it builds on, and reads the style in your components.json to pick the Base UI or Radix build.
Usage
"use client"
import { useState } from "react"
import { KanbanBoard } from "@/components/ui/kanban-board"
interface Task {
id: string
title: string
}
export function ProjectBoard() {
const [tasks, setTasks] = useState<Record<string, Task[]>>({
todo: [{ id: "1", title: "Refactor API" }],
doing: [{ id: "2", title: "Add unit tests" }],
done: [{ id: "3", title: "Update docs" }],
})
return (
<KanbanBoard
aria-label="Sprint tasks"
columns={[
{ id: "todo", title: "To do" },
{ id: "doing", title: "In progress" },
{ id: "done", title: "Done" },
]}
value={tasks}
onValueChange={setTasks}
onMove={(task, from, to, index) => {
console.log(`Moved ${task.title} from ${from} to ${to} at index ${index}`)
}}
/>
)
}Examples
Granular moves with onMove
onMove reports the exact card, previous column, target column, and index so you can persist changes without diffing the full board.
New leads
2Contacted
1Negotiation
0Closed won
1Empty column states
renderEmptyColumn customizes the drop target when a column has no cards.
Reported
2Triaged
0Resolved
0API reference
KanbanBoard
Multi-column task board for moving cards between workflow stages with keyboard and HTML5 drag-and-drop support. Space picks up a card, arrow keys move it within or across columns, Space drops it, and Escape cancels.
| Prop | Type | Default |
|---|---|---|
columnsRequiredKanbanColumn[]List of columns with id, title, and optional description. | KanbanColumn[] | |
valueRecord<string, T[]>Controlled map of column ids to card arrays. | Record<string, T[]> | |
defaultValueRecord<string, T[]>Default{}Initial value when uncontrolled. | Record<string, T[]> | {} |
onValueChange(value: Record<string, T[]>) => voidCalled when any card is moved or reordered. | (value: Record<string, T[]>) => void | |
onMove(card: T, fromColumnId: string, toColumnId: string, toIndex: number) => voidFires when a card is moved between columns or reordered within a column, reporting the specific transition. | (card: T, fromColumnId: string, toColumnId: string, toIndex: number) => void | |
renderCard(card: T, info: { columnId: string; index: number; isGrabbed: boolean }) => ReactNodeRender function for each card. | (card: T, info: { columnId: string; index: number; isGrabbed: boolean }) => ReactNode | |
renderColumnHeader(column: KanbanColumn, cards: T[]) => ReactNodeCustom render function for column headers. | (column: KanbanColumn, cards: T[]) => ReactNode | |
renderEmptyColumn(column: KanbanColumn) => ReactNodeCustom placeholder rendered when a column has no cards. | (column: KanbanColumn) => ReactNode | |
getCardId(card: T, index: number) => stringDefaultgetDefaultCardIdReturns a unique key for each card. | (card: T, index: number) => string | getDefaultCardId |
getCardLabel(card: T, index: number) => stringDefaultgetDefaultCardLabelReturns accessible label for screen readers and live region announcements. | (card: T, index: number) => string | getDefaultCardLabel |
disabledbooleanDefaultfalseDisables drag-and-drop and keyboard grabbing. | boolean | false |
Other props go to the <div>.
kanban-board-utils
moveCard<T>(board: Record<string, readonly T[] | undefined>, cardId: string, toColumnId: string, toIndex: number, getCardId?: (card: T, index: number) => string): MoveCardResult<T>; findCardLocation<T>(board: Record<string, readonly T[] | undefined>, cardId: string, getCardId?: (card: T, index: number) => string): KanbanCardLocation<T> | null; reorderCardInColumn<T>(cards: readonly T[], fromIndex: number, toIndex: number): T[]; getPickupAnnouncement(cardLabel: string, columnTitle: string, index: number, total: number): string; getMoveAnnouncement(cardLabel: string, columnTitle: string, index: number, total: number): string; getDropAnnouncement(cardLabel: string, columnTitle: string, index: number, total: number): string; getCancelAnnouncement(cardLabel: string, originalColumnTitle: string, originalIndex: number, total: number): stringPure logic functions for moving cards between columns, finding card locations, and formatting ARIA live region announcements. Import from @/lib/kanban-board-utils.