Kanban Board
Stage columns in one row. Cards move between columns by drag or by keyboard, each column header carries a count and a total, and parked stages fold into side rails.
Preview
The board is drawn for the Paper theme: pick Paper in the theme switcher and flip light and dark to see columns and cards told apart by tone alone. Drag a card, or focus one and press Space, →, Space. Click a side rail to open it.
Nothing here yet.
Press Space to pick up a card, Left and Right arrows to choose a column, Space to drop, Escape to cancel.
Installation
npx visor add kanban-boardThis copies files into your project:
blocks/kanban-board/kanban-board.tsx— the block componentblocks/kanban-board/kanban-board.module.css— the styles
It installs card as a dependency. Add --with-suggested for status-dot and chip, which most card designs use.
Usage
The block owns no data. You pass columns, render the inside of each card, and update your data in onMove. Persistence, optimistic state and Undo stay with you.
'use client';
import * as React from 'react';
import { KanbanBoard, type KanbanBoardColumn } from '@/blocks/kanban-board/kanban-board';
export function Pipeline({ deals, stages }: Props) {
const [board, setBoard] = React.useState(deals);
const columns: KanbanBoardColumn<Deal>[] = stages.map((stage) => ({
id: stage.id,
label: stage.label,
total: formatMoney(sum(board[stage.id])),
items: board[stage.id],
empty: 'Nothing here yet.',
}));
return (
<KanbanBoard
aria-label="Pipeline"
columns={columns}
rails={['paused', 'archived']}
getItemLabel={(deal) => deal.name}
renderCard={(deal) => <DealCard deal={deal} />}
onCardOpen={(deal) => router.push(`/deals/${deal.id}`)}
renderColumnFooter={(column) => <AddDealButton stage={column.id} />}
onMove={(id, to) => {
setBoard((prev) => moveDeal(prev, id, to)); // optimistic
saveStage(id, to).catch(() => setBoard(deals)); // roll back on failure
}}
/>
);
}Anatomy
- Columns — one per entry in
columns, in order, side by side. The board scrolls sideways when the columns no longer fit. - Column header — the label in uppercase, the card count, and the optional
totalat the right edge. - Cards — a
Cardsurface per item.renderCardfills it; the block owns the surface, focus, drag and keys. - Drop hint — while a card is held over a column, a "Drop in …" slot opens at the top of that column and the column tints.
- Side rails — columns named in
railsdraw as narrow vertical rails (Paused · 3). A rail opens into a full column on click, and accepts drops while collapsed. An open rail's header label collapses it again.
Moving cards
- Drag — native HTML drag and drop, no extra dependency. Drop on any open column or collapsed rail.
- Keyboard — focus a card and press Space to pick it up. ← and → choose the column (rails included), Space or Enter drops, Escape cancels. A drop on a collapsed rail opens it, and focus follows the card to its new column.
- Focus — with nothing held, the arrow keys move focus between cards: up and down within a column, left and right to the nearest card in the next column that has any. Enter calls
onCardOpen.
onMove(itemId, toColumn) fires only when the card lands in a different column. Drops of anything that is not one of the board's cards are ignored.
Accessibility
- Each column is a labelled region holding a list; each card is a focusable list item described by the keyboard instructions.
- Every pick-up, column change, drop and cancel is announced through a polite
aria-liveregion, usinggetItemLabelfor the card's name. - Collapsed rails are buttons with
aria-expanded="false"and a label that includes the card count.
Theming
Columns sit on --surface-card and cards on --surface-popover, so a card reads lighter than its column in light and dark. There are no borders. A held card tilts and lifts onto --shadow-lg; the drop hint uses --surface-accent-subtle and --text-link.
Props
See KanbanBoardProps in blocks/kanban-board/kanban-board.tsx. In summary:
- Data —
columns(required):{ id, label, total?, items, empty? }[]. Items need a stringid. - Cards —
renderCard(item, column)(required),getItemLabel(item)(required),onCardOpen(item). - Moves —
onMove(itemId, toColumn)(required). - Layout —
rails(column ids shown collapsed),renderColumnFooter(column).
About Blocks
Blocks are complete UI patterns made up of multiple Visor components. Unlike individual components, blocks represent larger, composed sections of UI — such as admin shells, login forms, or dashboard panels.
Blocks are copy-and-own, just like components. Install them into your project and customize freely.