React Native · Components
Kanban
Kanban board: manages cards by dragging them between stages (columns) and optional swimlanes.
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
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
componentKanban board: manages cards by dragging them between stages (columns) and optional swimlanes. The same data and the same move rules as Kanban on web (the calculations are shared in core).
- Dragging: Long-press a card, then drag; a copy of the card follows the finger and the drop position is shown with a line. Near the edges the board scrolls sideways and the column up/down by itself. Column headers can also be long-pressed and moved (
onColumnsChange). - Rules: WIP limit (
limit,wip="block"),droppable: false,canDrop; when not allowed the line turns red and the card stays in place. - Optimistic saving: If
onMovereturns a Promise the card moves at once; if it rejects it returns to its old place and it is announced. - Phone: Columns take the board's width and snap column by column; there are column tabs on top.
- Accessibility: With a screen reader, cards move without dragging via the card's actions (previous/next column, up/down); moves are announced.
- Smooth with thousands of cards: in a board without swimlanes the columns are virtualized.
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.
KanbanSize
typeCard size: padding and text.
KanbanCardState
interfaceSecond argument of KanbanProps.renderCard.
| Name | Type | Description |
|---|---|---|
column | KanbanColumn | The card's column. |
lane | KanbanLane | undefined | The card's swimlane (undefined without lanes). |
overlay | boolean | The copy dragged under the finger is being drawn. |
lifted | boolean | Being dragged (the card in place looks dimmed). |
pending | boolean | The onMove Promise is in progress. |
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 place. |
to | KanbanPlace | New place. |
afterId | string | null | The card it was dropped right after (null if dropped at the top). |
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 will be added.
| Name | Type | Description |
|---|---|---|
column | string | Column id. |
lane | string | undefined | Swimlane id (undefined without lanes or for the "Other" lane). |
KanbanApi
interfaceTools obtained via apiRef to control the Kanban from outside.
| Name | Type | Description |
|---|---|---|
focus | (id?: string) => void | Makes a card visible (for screen readers too). |
scrollToColumn | (id: string) => void | Makes a column visible (scrolls to that column on a phone). |
scrollToItem | (id: string) => void | Makes a card's column and the card visible. |
KanbanStyles
interfaceStyles of the inner parts of Kanban.
| Name | Type | Description |
|---|---|---|
root? | ViewStyle | Board. |
column? | ViewStyle | Column. |
card? | ViewStyle | Card frame. |
KanbanProps
interfaceProps of the Kanban component (same names as on web).
| 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. When given, column headers can be long-pressed and dragged. | |
items? | readonly KanbanItem<T>[] | Cards (controlled). The order is the order within a column. See KanbanItem. | |
defaultItems? | readonly KanbanItem<T>[] | Initial cards in uncontrolled use. | |
onItemsChange? | (items: KanbanItem<T>[]) => void | Called with the new array when cards change (move, undo). | |
lanes? | readonly KanbanLane[] | Swimlanes. When given the board is split into horizontal strips. | |
onMove? | (info: KanbanMoveInfo<T>) => void | Promise<unknown> | Called when a card is moved. If it returns a Promise the move shows at once (optimistic) and the card stays in a "saving" state until it settles; if the Promise rejects the card returns to its old place and it is announced. | |
canDrop? | (item: KanbanItem<T>, to: KanbanCreatePlace) => boolean | Can the card be dropped into this cell? A cell returning false is marked red and the card stays in its old place. | |
wip? | "warn" | "block" | "warn" | When the WIP limit is exceeded: "warn" turns the counter red but allows dropping; "block" prevents dropping cards from another column into a full one. |
draggable? | boolean | true | With false cards cannot be dragged. |
renderCard? | (item: KanbanItem<T>, state: KanbanCardState) => ReactNode | Render the card content yourself; the frame, dragging and menu stay with the board. | |
onAction? | (item: KanbanItem<T>) => void | When a card is pressed (e.g. a detail window). | |
cardMenu? | (item: KanbanItem<T>) => readonly MenuEntry[] | Card menu: opened with the "…" button in the card's corner. | |
columnMenu? | (column: KanbanColumn) => readonly MenuEntry[] | Column menu: the "…" button in the header. | |
columnSummary? | (items: KanbanItem<T>[], column: KanbanColumn) => ReactNode | A summary added to the column header after the counter; called with the visible cards. | |
onCreate? | (title: string, place: KanbanCreatePlace) => void | Promise<unknown> | When given, "Add card" appears below the columns (cells in a board with swimlanes); the typed title comes here. You add the card to items. | |
filter? | (item: KanbanItem<T>) => boolean | Cards to show (search, assignee filter…). The WIP counter counts all cards. | |
collapsible? | boolean | true | Columns can be collapsed. |
collapsedColumns? | readonly string[] | Collapsed columns (controlled). | |
defaultCollapsedColumns? | readonly string[] | Initially collapsed columns in uncontrolled use. | |
onCollapsedColumnsChange? | (ids: string[]) => void | When the collapsed columns change. | |
collapsedLanes? | readonly string[] | Closed swimlanes (controlled). | |
defaultCollapsedLanes? | readonly string[] | Initially closed swimlanes in uncontrolled use. | |
onCollapsedLanesChange? | (ids: string[]) => void | When the closed swimlanes change. | |
storageKey? | string | Collapsed columns and closed swimlanes are stored in storage under this key. Ignored in controlled use. | |
storage? | PreferenceStorage | Where the state is stored (a @yasinsensoy/native/storage store can be passed directly). | |
size? | KanbanSize | "md" | Card density. |
columnWidth? | number | 288 | Column width (dp). On a phone a column fills the screen. |
snap? | boolean | true | On narrow widths (below 576 dp) columns take the board's width and snap column by column when scrolled; column tabs appear on top. |
loading? | boolean | Shows skeleton cards in the 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. See KanbanMessages. | |
apiRef? | Ref<KanbanApi> | Board API. See KanbanApi. | |
effect? | EffectProp | Effect of the cards (e.g. "lift"). Defaults to appearance.defaults.kanban.effect. | |
styles? | KanbanStyles | Styles of the inner parts. | |
testID? | string | Test id. |
KanbanTag
typeA label on a card (e.g. "Bug", "Frontend").
KanbanAssignee
interfaceA person assigned to a card; shown with AvatarGroup.
| Name | Type | Description |
|---|---|---|
name | string | Person's name; initials and tooltip are generated from it. |
src? | string | Photo URL. |
KanbanItem
typeA card on the Kanban board (same fields as on web). Cards are kept in a single flat array; column (and lane) says which column (and swimlane) the card sits in, and its order within the column is its order in the array.
KanbanColumn
typeA column (stage) of the Kanban board.
KanbanLane
typeA 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. |
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). |