Kanban

A composable board layout with draggable columns, draggable cards, and grouped item movement.

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

Use getKanbanItemsAfterDrag while dragging cards across columns, then use getSortableItemsAfterDrag when columns are reordered.

API Reference

Kanban.Root

Horizontal sortable root for kanban columns. Accepts the same props as Sortable.Root.

Kanban.Column

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

PropTypeDefaultDescription
id*string-Stable column id.
index*number-Current column index.
renderReactElement-Replaces the default column element.

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.

PropTypeDefaultDescription
orientation"horizontal" | "vertical""vertical"Overrides the default vertical card list layout.
renderReactElement-Replaces the default list element.

Kanban.Item

Registers a draggable card.

PropTypeDefaultDescription
id*string-Stable card id.
index*number-Current card index inside its column.
group*string-Column id for the card's current group.

getKanbanItemsAfterDrag

Returns the next grouped item state after moving a card within or between columns.

setItems((items) => getKanbanItemsAfterDrag(items, event));
ParameterTypeDescription
itemsKanbanItemsCurrent mapping of column ids to card ids.
eventDragOverEvent | DragEndEventEvent from Kanban.Root.

getKanbanColumnTargetId

Reads a target column id from dnd-kit target data. Returns null when the data is not a kanban column target.

enum KanbanDnd

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

type KanbanItems

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