Skip to Content
Notion UI

Kanban

A board with draggable columns and cards.

Kanban Board

Installation

pnpm add @notion-kit/ui

Anatomy

<Kanban.Root>
  <Kanban.Column>
    <Kanban.ColumnHeader />
    <Kanban.ColumnContent>
      <Kanban.Item />
    </Kanban.ColumnContent>
  </Kanban.Column>
</Kanban.Root>

Examples


Board

Keep the accepted board value in application state. Kanban.Root supplies a projected value for rendering during a gesture, then calls onMove once for a changed, valid drop. Escape, an outside drop, and an unchanged placement leave application state untouched.

Kanban Board

const [value, setValue] = useState<KanbanValue>(initialValue);

<Kanban.Root
  value={value}
  onMove={(move) => setValue((current) => applyKanbanMove(current, move))}
  renderOverlay={(source) => <BoardPreview source={source} />}
>
  {(projected) =>
    projected.columnOrder.map((columnId, index) => (
      <Kanban.Column key={columnId} id={columnId} index={index}>
        <Kanban.ColumnHeader>{columnId}</Kanban.ColumnHeader>
        <Kanban.ColumnContent>
          {projected.items[columnId]?.map((itemId, itemIndex) => (
            <Kanban.Item
              key={itemId}
              id={itemId}
              index={itemIndex}
              group={columnId}
            >
              <Kanban.ItemHandle />
              {itemId}
            </Kanban.Item>
          ))}
        </Kanban.ColumnContent>
      </Kanban.Column>
    ))
  }
</Kanban.Root>;

Render the supplied projection, including each card's current column and local index. Keep empty columns in columnOrder with an empty array in items so they remain drop targets. Card bodies support pointer dragging; Kanban.ItemHandle supplies a separate keyboard handle. Column headers act as column handles.

renderOverlay should return a display-only card or column. Reuse its visual content, but omit draggable components, editors, and action controls. Root makes the preview inert. Authoritative membership or ordering changes invalidate an active gesture; changing contextKey also invalidates it when permissions or grouping configuration change.

For persisted boards, handle onMove with one application command that updates the card's group and position together. Use canMove to reject destinations that cannot accept the card. A controlled parent may reject a move by keeping value unchanged. When sorting overrides manual order, hold the completed move for confirmation before clearing the sort and committing it.

In TableView, the selected grouping method must define getDropValue to allow transfers between groups. Exact text, checkbox, select, and multi-select groups supply this capability. Derived prefixes, number ranges, and date buckets allow same-group reordering but reject transfers. A sorted Board asks to remove sorting before applying a card move. Column reorders apply immediately.

API Reference

Kanban.Root

Controls local drag projection and reports completed moves. Also accepts Sortable.Root props except its children and raw drag lifecycle callbacks.

Prop

Type

Kanban.Column

Registers a draggable column. Accepts Sortable.Item props in addition to the following.

Prop

Type

Kanban.ColumnHeader

Renders a column header that also acts as the column drag handle. Accepts standard <div> props.

Kanban.ColumnContent

Vertical sortable list and droppable target for cards in the current column.

Prop

Type

Kanban.Item

Registers a draggable card.

Prop

Type

Kanban.ItemHandle

Keyboard drag handle for a card. Accepts Sortable.Handle props and defaults to the accessible label Move card. Its click and keyboard events do not bubble to the card's open action.

applyKanbanMove

Applies a completed semantic move to a board value. beforeId: null appends to the destination. Invalid and unchanged moves return the original value.

setValue((current) => applyKanbanMove(current, move));

Prop

Type

type KanbanValue

interface KanbanValue {
  columnOrder: string[];
  items: KanbanItems;
}

type KanbanMove

type KanbanMove =
  | {
      type: KanbanDnd.Item;
      id: string;
      columnId: string;
      beforeId: string | null;
    }
  | { type: KanbanDnd.Column; id: string; beforeId: string | null };

type KanbanSource

type KanbanSource =
  { type: KanbanDnd.Item; id: string } | { type: KanbanDnd.Column; id: string };

enum KanbanDnd

ValueDescription
ItemDrag type for cards.
ColumnDrag type for columns.
ColumnContentDroppable type for card containers.

type KanbanItems

type KanbanItems = Record<string, string[]>;

On this page