Web · Components
Kanban
Kanban board: a board that splits work into stages (columns) and optional lanes, with cards moved by dragging.
Live example
Preview
Ideas
2 cardsNot planned yet
To do
3 cardsIn progress
2 cards / 3In review
1 cards / 2Done
2 cardsDrag with the mouse; on touch, press and hold a card. With the keyboard, arrows move while a card is focused, Space picks up/drops, Esc cancels. Cards can't move straight from "Ideas" to "Done" (canDrop).
Code
Events
- Events appear here when you interact with the preview.
Sales pipeline: custom card view (renderCard) and column total (columnSummary)
Lead
4 cards₺610.056Meeting
4 cards₺761.732Proposal
3 cards₺757.542Won
3 cards₺471.2996,000 cards: virtualization per column
Incoming requests
2000 cardsAssigned
2000 cardsResolved
2000 cards6,000 cards; only visible ones are rendered in each column.
Import
Kanban board: a board that splits work into stages (columns) and optional lanes, with cards moved by dragging. For flows like task tracking, sales pipelines, hiring and support tickets.
The data is a single flat items array; each card's column (and lane) field sets its place, and its order in the array sets its order in the column. On a move, onItemsChange is called with the new array, and onMove with the info to send to the server (new place, previous/next card).
- Drag and drop: Grab a card with the mouse and drag; the card follows the cursor, a gap opens where it will drop and the other cards slide to make room. On release the card glides into the gap. The board (and column) auto-scrolls near the edges. Esc cancels. Columns are also dragged by their header (see
onColumnsChange). - Touch: A short long press on a card (with a haptic) lifts it, then it is dragged; normal scrolling isn't broken. The menu is on the "…" button.
- Keyboard: Move between cards with arrows (a single tab stop), Enter opens, Space lifts the card; choose a place with the arrows and drop with Space/Enter, Esc cancels. Each step is announced to screen readers ("In progress, 2/5"). Shift+F10 opens the card menu.
- WIP limit: With the column's
limitthe counter shows3/5, turns yellow at the limit and red when exceeded;wip="block"prevents dropping into a full column. Add your own rule withcanDrop. - Lanes: With
lanescards are split into horizontal strips (person, priority, team); lanes collapse and cards move between lanes. - Optimistic save: If
onMovereturns a Promise the card moves immediately; on error it returns to its old place. - Mobile: In a narrow area columns are screen-wide and snap column by column when scrolling; the tabs on top jump between columns. While dragging, reaching the screen edge moves to the neighboring column.
- Performance: Long columns render only visible cards (
virtualize); while dragging the cursor copy moves in the DOM, and React renders only when the drop position changes.
Examples
moveKanbanItem
functionMoves a card to its new place on the board and returns the new array (the input is not changed). The card's column/lane fields are updated; its order is given with beforeId or afterId. Also used to apply a move from the server (e.g. a live update) to the board.
Examples
moveKanbanColumn
functionChanges a column's position; index is relative to the array before the move (where it was dropped). The input is not changed.
kanbanWipState
functionWIP state: "ok" without a limit or below it, "full" at the limit, "over" above it.
KanbanCardState
interfaceSecond argument of KanbanProps.renderCard.
| Name | Type | Description |
|---|---|---|
column | KanbanColumn | Column of the card. |
lane | KanbanLane | undefined | Lane of the card (undefined without lanes). |
overlay | boolean | The copy dragged under the cursor is being drawn. |
lifted | boolean | Being moved by keyboard (the card looks lifted). |
pending | boolean | The onMove Promise is pending. |
KanbanMoveInfo
interfaceInformation for KanbanProps.onMove.
| Name | Type | Description |
|---|---|---|
id | string | Id of the moved card. |
item | KanbanItem<T> | The moved card (as it was before the move). |
from | KanbanPlace | Old position. |
to | KanbanPlace | New position. |
afterId | string | null | The card it was dropped right after (null if dropped at the top); for telling the server the order. |
beforeId | string | null | The card it was dropped right before (null if dropped at the bottom). |
items | KanbanItem<T>[] | All cards after the move. |
KanbanColumnMoveInfo
interfaceSecond argument of KanbanProps.onColumnsChange.
| Name | Type | Description |
|---|---|---|
id | string | Id of the moved column. |
from | number | Old index. |
to | number | New index. |
KanbanCreatePlace
interfaceSecond argument of KanbanProps.onCreate: where the card is added.
| Name | Type | Description |
|---|---|---|
column | string | Column id. |
lane | string | undefined | Lane id (undefined without lanes or for the "Other" lane). |
KanbanApi
interfaceTools obtained via apiRef to control Kanban from outside.
| Name | Type | Description |
|---|---|---|
focus | (id?: string) => void | Focuses the card (the active card if omitted); makes it visible if needed. |
scrollToColumn | (id: string) => void | Makes the column visible (scrolls to that column on mobile). |
scrollToItem | (id: string) => void | Makes the card's column and the card visible. |
KanbanProps
interfaceProps of the Kanban component.
Extends: Omit<ComponentProps<"div">, "children" | "onChange" | "ref">
| Name | Type | Default | Description |
|---|---|---|---|
columns | readonly KanbanColumn[] | Columns (left to right). | |
onColumnsChange? | (columns: KanbanColumn[], info: KanbanColumnMoveInfo) => void | Called with the new array when columns are reordered by dragging. If given, column headers become draggable (mouse, touch and keyboard); store the array and pass it back as columns. | |
items? | readonly KanbanItem<T>[] | Cards (controlled). Their order is the order within the column. See KanbanItem. | |
defaultItems? | readonly KanbanItem<T>[] | Initial cards when uncontrolled. | |
onItemsChange? | (items: KanbanItem<T>[]) => void | Called with the new array when cards change (move, undo). | |
lanes? | readonly KanbanLane[] | Lanes (swimlanes). If given, the board is split into horizontal strips; the card's lane is its lane field. Cards can be dragged to another lane too. | |
onMove? | (info: KanbanMoveInfo<T>) => void | Promise<unknown> | Called when a card is moved. If it returns a Promise, the move shows immediately (optimistic) and the card stays in a "saving" state until it settles; if the Promise rejects, the card returns to its old place and this is announced. | |
canDrop? | (item: KanbanItem<T>, to: KanbanCreatePlace) => boolean | Can the card be dropped into this cell? Asked once per cell while dragging; a cell that returns false is marked with a red frame and the card stays in its old place. (E.g. "Done" may only be reached from "In review".) | |
wip? | "warn" | "block" | "warn" | What happens when the WIP limit (KanbanColumn.limit) is exceeded: "warn" the counter turns red but dropping is allowed; "block" cards from other columns cannot be dropped into a full column. |
draggable? | boolean | true | If false, cards cannot be dragged. |
renderCard? | (item: KanbanItem<T>, state: KanbanCardState) => ReactNode | Render the card's content yourself. The card's frame, focus, dragging and menu button stay with the board; here you return only the inside. | |
onAction? | (item: KanbanItem<T>) => void | Opening the card on click or with Enter (e.g. a detail window). | |
cardMenu? | (item: KanbanItem<T>) => readonly MenuEntry[] | Card menu: opens on right-click, with Shift+F10 or with the "…" button in the card's corner. Items' shortcut values work on the focused card. | |
columnMenu? | (column: KanbanColumn) => readonly MenuEntry[] | Column menu: the "…" button in the header and right-click on the header. | |
columnSummary? | (items: KanbanItem<T>[], column: KanbanColumn) => ReactNode | Summary added to the column header after the counter (e.g. total points). Called with the filtered visible cards. | |
onCreate? | (title: string, place: KanbanCreatePlace) => void | Promise<unknown> | If given, "Add card" appears under columns (cells in a laned board); the typed title comes here. You add the card to items. If it returns a Promise the box waits until it settles; the box stays open for the next card. | |
filter? | (item: KanbanItem<T>) => boolean | Cards to show (search, assignee filter…). Hidden cards stay in place; drag reordering applies relative to the visible ones. The WIP counter counts all cards. | |
collapsible? | boolean | true | Columns can be collapsed (button in the header). |
collapsedColumns? | readonly string[] | Collapsed columns (controlled). | |
defaultCollapsedColumns? | readonly string[] | Initially collapsed columns when uncontrolled. | |
onCollapsedColumnsChange? | (ids: string[]) => void | When the collapsed columns change. | |
collapsedLanes? | readonly string[] | Collapsed lanes (controlled). | |
defaultCollapsedLanes? | readonly string[] | Initially collapsed lanes when uncontrolled. | |
onCollapsedLanesChange? | (ids: string[]) => void | When the collapsed lanes change. | |
storageKey? | string | Collapsed columns and lanes are stored in localStorage under this key; they look the same after a page reload. Ignored when controlled. | |
virtualize? | boolean | "auto" | "auto" | Renders only visible cards (thousands of cards per column). "auto": in columns with more than 60 cards. Works in a board without lanes and when the board has a height (className="h-[70vh]"). |
size? | KanbanSize | "md" | Card density. |
columnWidth? | number | 288 | Column width (px). On narrow screens a column fills the screen. |
snap? | boolean | true | In a narrow area (below ≈ 576 px) columns become screen-wide and snap column by column when scrolling; column tabs appear on top. If false, the desktop layout is kept. |
loading? | boolean | Shows skeleton cards in columns while cards load. | |
empty? | ReactNode | Content shown in an empty column. | |
label? | string | Accessible name of the board. | |
messages? | Partial<KanbanMessages> | Texts of this board; for the whole app use the ui.kanban namespace of the dictionary. See KanbanMessages. | |
apiRef? | Ref<KanbanApi> | Board API. See KanbanApi. | |
cardClassName? | string | Classes added to the card's frame. | |
effect? | EffectProp | Effect or effects of the cards (e.g. "lift", ["tilt", "glow"]). If omitted, UIProvider appearance.defaults.kanban.effect. See BuiltinEffect. |
KanbanSize
typeSize of the card: padding and text.
KanbanMessages
interfaceKanban texts. Placeholders like {name} are filled in. Changed app-wide in the dictionary's ui.kanban namespace, or for one board with the board's messages prop.
| Name | Type | Description |
|---|---|---|
board | string | Default accessible name of the board. |
count | string | Screen reader text for the column header counter: {count}. |
empty | string | Text in an empty column. |
add | string | Add card button. |
addPlaceholder | string | Placeholder of the add-card box. |
cancel | string | Button that closes the add box. |
collapse | string | Button that collapses the column. |
expand | string | Button that expands a collapsed column. |
cardActions | string | Card menu button. |
columnActions | string | Column menu button. |
dragColumn | string | Column move handle. |
noLane | string | Lane for cards without a lane. |
wipFull | string | WIP limit reached. |
wipOver | string | WIP limit exceeded. |
wipBlocked | string | Drop into a full column blocked: {column}, {limit}. |
cardHint | string | Keyboard hint of a card (screen reader). |
columnHint | string | Keyboard hint of the column handle (screen reader). |
pickedUp | string | Card picked up: {title}, {place}. |
over | string | Card over a new place: {place}. |
dropped | string | Card dropped: {title}, {place}. |
place | string | Card position: {column}, {position}, {total}. |
placeInLane | string | Position with lanes: {lane}, {column}, {position}, {total}. |
columnPickedUp | string | Column picked up with the keyboard: {title}, {position}, {total}. |
columnOver | string | New column position: {position}, {total}. |
columnDropped | string | Column dropped: {title}, {position}, {total}. |
cancelled | string | Move cancelled. |
moveFailed | string | Move failed on the server and was reverted: {title}. |
overdue | string | Overdue date. |
loading | string | Loading. |
moveLeft | string | Screen reader action: move the card to the previous column (native). |
moveRight | string | Screen reader action: move the card to the next column (native). |
moveUp | string | Screen reader action: move the card up one (native). |
moveDown | string | Screen reader action: move the card down one (native). |
KanbanTag
typeA tag on a card (e.g. "Bug", "Frontend"). See KanbanTag in core.
KanbanAssignee
typePerson assigned to the card; shown with AvatarGroup.
KanbanItem
typeA card on the Kanban board. Cards are kept in a single flat array; column (and lane) say which column (and lane) the card is in, and its order in the array is its order in the column. See KanbanItem in core.
KanbanColumn
typeA column (stage) of the Kanban board.
KanbanLane
typeA lane (swimlane) of the Kanban board.
KanbanPlace
interfacePosition of a card on the board.
| Name | Type | Description |
|---|---|---|
column | string | Column id. |
lane | string | undefined | Lane id (undefined without lanes or in the "Other" lane). |
index | number | Index within the cell (column × lane); items hidden by a filter count too. |
KanbanTarget
interfaceTarget of moveKanbanItem.
| Name | Type | Description |
|---|---|---|
column | string | New column. |
lane? | string | undefined | New lane; undefined removes the lane. |
beforeId? | string | null | Place right before this card. |
afterId? | string | null | Without beforeId, place right after this card. With neither, at the end of the array. |