Command palette

@yasinsensoy/web

Web · Components

Kanban

Kanban board: a board that splits work into stages (columns) and optional lanes, with cards moved by dragging.

19 exports

Live example

Preview

Ideas

2 cards

Not planned yet

Design
Automatic contrast check for the dark theme
Command palette (⌘K)
Quick search and running commands inside the app.
CÖ

To do

3 cards
ErrorPayment
3D Secure error on the checkout page
Overdue
MK
Frontend
Profile photo cropping
ZDAY
Translate the email templates to Turkish
💬 4

In progress

2 cards / 3
Performance
Slowness in the order list
Filtering 100k rows takes 2 s; virtualization and an index.
AY
Frontend
Notification preferences page
📎 2
CÖZDMK+1

In review

1 cards / 2
Security
SMS verification on the sign-in page
MK

Done

2 cards
Kanban board
Drag and drop, WIP limit, swimlanes, mobile.
AY
Pagination component

Drag 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

import { KanbanItem, Kanban } from "@yasinsensoy/web";

const [items, setItems] = useState<KanbanItem[]>(cards);

<Kanban
  label="Project board"
  className="h-[34rem]"
  columns={[
    { id: "todo", title: "To do", tone: "primary" },
    { id: "doing", title: "In progress", tone: "warning", limit: 3 },
    { id: "done", title: "Done", tone: "success" },
  ]}
  items={items}
  onItemsChange={setItems}
  onColumnsChange={setColumns}
  onMove={({ id, to, afterId }) => api.cardMove(id, to.column, afterId)}
  onCreate={(title, { column }) =>
    setItems((k) => [...k, { id: crypto.randomUUID(), column, title: title }])
  }
  onAction={(card) => ayrintiyiAc(card.id)}
  cardMenu={(card) => [
    { label: "Sil", icon: "trash", tone: "danger", shortcut: "Delete", onSelect: () => remove(card.id) },
  ]}
/>

Events

  1. Events appear here when you interact with the preview.

Sales pipeline: custom card view (renderCard) and column total (columnSummary)

Lead

4 cards₺610.056
Anatolia Logistics%10
₺25.000
Anatolia Logistics%10
₺176.676
Anatolia Logistics%10
₺328.352
Anatolia Logistics%10
₺80.028

Meeting

4 cards₺761.732
Aegean Textiles%35
₺62.919
Aegean Textiles%35
₺214.595
Aegean Textiles%35
₺366.271
Aegean Textiles%35
₺117.947

Proposal

3 cards₺757.542
Bosphorus Software%60
₺100.838
Bosphorus Software%60
₺252.514
Bosphorus Software%60
₺404.190

Won

3 cards₺471.299
Cappadocia Tourism%100
₺138.757
Cappadocia Tourism%100
₺290.433
Cappadocia Tourism%100
₺42.109

6,000 cards: virtualization per column

Incoming requests

2000 cards
VIP
Talep #1: Password reset
The customer wrote a second time, prioritize it.
Talep #4: Shipping delay
Talep #7: Refund request
Talep #10: Billing question
Talep #13: Password reset
Talep #16: Shipping delay
The customer wrote a second time, prioritize it.
Talep #19: Refund request
VIP
Talep #22: Billing question
Talep #25: Password reset
Talep #28: Shipping delay
Talep #31: Refund request
The customer wrote a second time, prioritize it.
Talep #34: Billing question
Talep #37: Password reset
Talep #40: Shipping delay
VIP
Talep #43: Refund request
Talep #46: Billing question
The customer wrote a second time, prioritize it.
Talep #49: Password reset
Talep #52: Shipping delay
Talep #55: Refund request

Assigned

2000 cards
Talep #2: Billing question
Talep #5: Password reset
VIP
Talep #8: Shipping delay
Talep #11: Refund request
The customer wrote a second time, prioritize it.
Talep #14: Billing question
Talep #17: Password reset
Talep #20: Shipping delay
Talep #23: Refund request
Talep #26: Billing question
The customer wrote a second time, prioritize it.
VIP
Talep #29: Password reset
Talep #32: Shipping delay
Talep #35: Refund request
Talep #38: Billing question
Talep #41: Password reset
The customer wrote a second time, prioritize it.
Talep #44: Shipping delay
Talep #47: Refund request
VIP
Talep #50: Billing question
Talep #53: Password reset
Talep #56: Shipping delay
The customer wrote a second time, prioritize it.

Resolved

2000 cards
Talep #3: Refund request
Talep #6: Billing question
The customer wrote a second time, prioritize it.
Talep #9: Password reset
Talep #12: Shipping delay
VIP
Talep #15: Refund request
Talep #18: Billing question
Talep #21: Password reset
The customer wrote a second time, prioritize it.
Talep #24: Shipping delay
Talep #27: Refund request
Talep #30: Billing question
Talep #33: Password reset
VIP
Talep #36: Shipping delay
The customer wrote a second time, prioritize it.
Talep #39: Refund request
Talep #42: Billing question
Talep #45: Password reset
Talep #48: Shipping delay
Talep #51: Refund request
The customer wrote a second time, prioritize it.
Talep #54: Billing question
VIP
Talep #57: Password reset

6,000 cards; only visible ones are rendered in each column.

Import

import { Kanban, moveKanbanItem, moveKanbanColumn, kanbanWipState } from "@yasinsensoy/web";

Kanban

componentClient component

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 limit the counter shows 3/5, turns yellow at the limit and red when exceeded; wip="block" prevents dropping into a full column. Add your own rule with canDrop.
  • Lanes: With lanes cards are split into horizontal strips (person, priority, team); lanes collapse and cards move between lanes.
  • Optimistic save: If onMove returns 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.
Kanban({ columns, onColumnsChange, items: itemsProp, defaultItems, onItemsChange, lanes, onMove, canDrop, wip, draggable, renderCard, onAction, cardMenu, columnMenu, columnSummary, onCreate, filter, collapsible, collapsedColumns: collapsedColumnsProp, defaultCollapsedColumns, onCollapsedColumnsChange, collapsedLanes: collapsedLanesProp, defaultCollapsedLanes, onCollapsedLanesChange, storageKey, virtualize, size, columnWidth, snap, loading, empty, label, messages: messagesProp, apiRef, cardClassName, effect, className, style, ...props }: KanbanProps<T>): JSX.Element

Examples

const [cards, setCards] = useState<KanbanItem[]>([
  { id: "1", column: "todo", title: "Landing page", tags: [{ label: "Design", tone: "primary" }] },
  { id: "2", column: "doing", title: "Payment integration", due: "2026-11-04" },
]);

<Kanban
  className="h-[70vh]"
  columns={[
    { id: "todo", title: "To do" },
    { id: "doing", title: "In progress", limit: 3, tone: "warning" },
    { id: "done", title: "Done", tone: "success" },
  ]}
  items={cards}
  onItemsChange={setCards}
  onMove={({ id, to, afterId }) => api.move(id, to.column, afterId)}
  onCreate={(title, { column }) =>
    setCards((c) => [...c, { id: crypto.randomUUID(), column, title }])
  }
  onAction={(card) => openDetails(card.id)}
/>

Moves 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.

moveKanbanItem(items: readonly K[], id: string, target: KanbanTarget): K[]

Examples

setItems((items) => moveKanbanItem(items, "k-12", { column: "done", beforeId: "k-3" }));

Changes a column's position; index is relative to the array before the move (where it was dropped). The input is not changed.

moveKanbanColumn(columns: readonly C[], id: string, index: number): C[]

WIP state: "ok" without a limit or below it, "full" at the limit, "over" above it.

kanbanWipState(count: number, limit: number | undefined): "ok" | "full" | "over"

Second argument of KanbanProps.renderCard.

NameTypeDescription
columnKanbanColumnColumn of the card.
laneKanbanLane | undefinedLane of the card (undefined without lanes).
overlaybooleanThe copy dragged under the cursor is being drawn.
liftedbooleanBeing moved by keyboard (the card looks lifted).
pendingbooleanThe onMove Promise is pending.

Information for KanbanProps.onMove.

NameTypeDescription
idstringId of the moved card.
itemKanbanItem<T>The moved card (as it was before the move).
fromKanbanPlaceOld position.
toKanbanPlaceNew position.
afterIdstring | nullThe card it was dropped right after (null if dropped at the top); for telling the server the order.
beforeIdstring | nullThe card it was dropped right before (null if dropped at the bottom).
itemsKanbanItem<T>[]All cards after the move.

Second argument of KanbanProps.onColumnsChange.

NameTypeDescription
idstringId of the moved column.
fromnumberOld index.
tonumberNew index.

Second argument of KanbanProps.onCreate: where the card is added.

NameTypeDescription
columnstringColumn id.
lanestring | undefinedLane id (undefined without lanes or for the "Other" lane).

KanbanApi

interface

Tools obtained via apiRef to control Kanban from outside.

NameTypeDescription
focus(id?: string) => voidFocuses the card (the active card if omitted); makes it visible if needed.
scrollToColumn(id: string) => voidMakes the column visible (scrolls to that column on mobile).
scrollToItem(id: string) => voidMakes the card's column and the card visible.

KanbanProps

interface

Props of the Kanban component.

Extends: Omit<ComponentProps<"div">, "children" | "onChange" | "ref">

NameTypeDefaultDescription
columnsreadonly KanbanColumn[]Columns (left to right).
onColumnsChange?(columns: KanbanColumn[], info: KanbanColumnMoveInfo) => voidCalled 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>[]) => voidCalled 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) => booleanCan 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?booleantrueIf false, cards cannot be dragged.
renderCard?(item: KanbanItem<T>, state: KanbanCardState) => ReactNodeRender 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>) => voidOpening 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) => ReactNodeSummary 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>) => booleanCards 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?booleantrueColumns can be collapsed (button in the header).
collapsedColumns?readonly string[]Collapsed columns (controlled).
defaultCollapsedColumns?readonly string[]Initially collapsed columns when uncontrolled.
onCollapsedColumnsChange?(ids: string[]) => voidWhen the collapsed columns change.
collapsedLanes?readonly string[]Collapsed lanes (controlled).
defaultCollapsedLanes?readonly string[]Initially collapsed lanes when uncontrolled.
onCollapsedLanesChange?(ids: string[]) => voidWhen the collapsed lanes change.
storageKey?stringCollapsed 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?number288Column width (px). On narrow screens a column fills the screen.
snap?booleantrueIn 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?booleanShows skeleton cards in columns while cards load.
empty?ReactNodeContent shown in an empty column.
label?stringAccessible 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?stringClasses added to the card's frame.
effect?EffectPropEffect or effects of the cards (e.g. "lift", ["tilt", "glow"]). If omitted, UIProvider appearance.defaults.kanban.effect. See BuiltinEffect.

Size of the card: padding and text.

type KanbanSize = "sm" | "md"

Kanban 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.

NameTypeDescription
boardstringDefault accessible name of the board.
countstringScreen reader text for the column header counter: {count}.
emptystringText in an empty column.
addstringAdd card button.
addPlaceholderstringPlaceholder of the add-card box.
cancelstringButton that closes the add box.
collapsestringButton that collapses the column.
expandstringButton that expands a collapsed column.
cardActionsstringCard menu button.
columnActionsstringColumn menu button.
dragColumnstringColumn move handle.
noLanestringLane for cards without a lane.
wipFullstringWIP limit reached.
wipOverstringWIP limit exceeded.
wipBlockedstringDrop into a full column blocked: {column}, {limit}.
cardHintstringKeyboard hint of a card (screen reader).
columnHintstringKeyboard hint of the column handle (screen reader).
pickedUpstringCard picked up: {title}, {place}.
overstringCard over a new place: {place}.
droppedstringCard dropped: {title}, {place}.
placestringCard position: {column}, {position}, {total}.
placeInLanestringPosition with lanes: {lane}, {column}, {position}, {total}.
columnPickedUpstringColumn picked up with the keyboard: {title}, {position}, {total}.
columnOverstringNew column position: {position}, {total}.
columnDroppedstringColumn dropped: {title}, {position}, {total}.
cancelledstringMove cancelled.
moveFailedstringMove failed on the server and was reverted: {title}.
overduestringOverdue date.
loadingstringLoading.
moveLeftstringScreen reader action: move the card to the previous column (native).
moveRightstringScreen reader action: move the card to the next column (native).
moveUpstringScreen reader action: move the card up one (native).
moveDownstringScreen reader action: move the card down one (native).

A tag on a card (e.g. "Bug", "Frontend"). See KanbanTag in core.

type KanbanTag = Core.KanbanTag<ReactNode>

Person assigned to the card; shown with AvatarGroup.

type KanbanAssignee = Core.KanbanAssignee

A 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.

type KanbanItem = Core.KanbanItem<T, ReactNode, IconProp>

A column (stage) of the Kanban board.

type KanbanColumn = Core.KanbanColumn<ReactNode, IconProp>

A lane (swimlane) of the Kanban board.

type KanbanLane = Core.KanbanLane<ReactNode, IconProp>

KanbanPlace

interface

Position of a card on the board.

NameTypeDescription
columnstringColumn id.
lanestring | undefinedLane id (undefined without lanes or in the "Other" lane).
indexnumberIndex within the cell (column × lane); items hidden by a filter count too.

KanbanTarget

interface

Target of moveKanbanItem.

NameTypeDescription
columnstringNew column.
lane?string | undefinedNew lane; undefined removes the lane.
beforeId?string | nullPlace right before this card.
afterId?string | nullWithout beforeId, place right after this card. With neither, at the end of the array.