Command palette

@yasinsensoy/native

React Native · Components

Kanban

Kanban board: manages cards by dragging them between stages (columns) and optional swimlanes.

20 exports

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 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/native";

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/native";

Kanban

component

Kanban 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 onMove returns 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.
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, storage, size, columnWidth, snap, loading, empty, label, messages: messagesProp, apiRef, effect, styles: parts, testID, }: KanbanProps<T>): JSX.Element

Examples

const [items, setItems] = useState(cards);
<Kanban
  style={{ flex: 1 }}
  columns={[
    { id: "todo", title: "To do" },
    { id: "doing", title: "In progress", limit: 3 },
    { id: "done", title: "Done", tone: "success" },
  ]}
  items={items}
  onItemsChange={setItems}
  onMove={({ id, to, afterId }) => api.moveCard(id, to.column, afterId)}
  onCreate={(title, { column }) => setItems((list) => [...list, { id: newId(), column, title }])}
/>

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"

Card size: padding and text.

type KanbanSize = "sm" | "md"

Second argument of KanbanProps.renderCard.

NameTypeDescription
columnKanbanColumnThe card's column.
laneKanbanLane | undefinedThe card's swimlane (undefined without lanes).
overlaybooleanThe copy dragged under the finger is being drawn.
liftedbooleanBeing dragged (the card in place looks dimmed).
pendingbooleanThe onMove Promise is in progress.

Information for KanbanProps.onMove.

NameTypeDescription
idstringId of the moved card.
itemKanbanItem<T>The moved card (as it was before the move).
fromKanbanPlaceOld place.
toKanbanPlaceNew place.
afterIdstring | nullThe card it was dropped right after (null if dropped at the top).
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 will be added.

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

KanbanApi

interface

Tools obtained via apiRef to control the Kanban from outside.

NameTypeDescription
focus(id?: string) => voidMakes a card visible (for screen readers too).
scrollToColumn(id: string) => voidMakes a column visible (scrolls to that column on a phone).
scrollToItem(id: string) => voidMakes a card's column and the card visible.

KanbanStyles

interface

Styles of the inner parts of Kanban.

NameTypeDescription
root?ViewStyleBoard.
column?ViewStyleColumn.
card?ViewStyleCard frame.

KanbanProps

interface

Props of the Kanban component (same names as on web).

NameTypeDefaultDescription
columnsreadonly KanbanColumn[]Columns (left to right).
onColumnsChange?(columns: KanbanColumn[], info: KanbanColumnMoveInfo) => voidCalled 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>[]) => voidCalled 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) => booleanCan 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?booleantrueWith false cards cannot be dragged.
renderCard?(item: KanbanItem<T>, state: KanbanCardState) => ReactNodeRender the card content yourself; the frame, dragging and menu stay with the board.
onAction?(item: KanbanItem<T>) => voidWhen 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) => ReactNodeA 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>) => booleanCards to show (search, assignee filter…). The WIP counter counts all cards.
collapsible?booleantrueColumns can be collapsed.
collapsedColumns?readonly string[]Collapsed columns (controlled).
defaultCollapsedColumns?readonly string[]Initially collapsed columns in uncontrolled use.
onCollapsedColumnsChange?(ids: string[]) => voidWhen the collapsed columns change.
collapsedLanes?readonly string[]Closed swimlanes (controlled).
defaultCollapsedLanes?readonly string[]Initially closed swimlanes in uncontrolled use.
onCollapsedLanesChange?(ids: string[]) => voidWhen the closed swimlanes change.
storageKey?stringCollapsed columns and closed swimlanes are stored in storage under this key. Ignored in controlled use.
storage?PreferenceStorageWhere the state is stored (a @yasinsensoy/native/storage store can be passed directly).
size?KanbanSize"md"Card density.
columnWidth?number288Column width (dp). On a phone a column fills the screen.
snap?booleantrueOn narrow widths (below 576 dp) columns take the board's width and snap column by column when scrolled; column tabs appear on top.
loading?booleanShows skeleton cards in the columns while cards load.
empty?ReactNodeContent shown in an empty column.
label?stringAccessible name of the board.
messages?Partial<KanbanMessages>Texts of this board. See KanbanMessages.
apiRef?Ref<KanbanApi>Board API. See KanbanApi.
effect?EffectPropEffect of the cards (e.g. "lift"). Defaults to appearance.defaults.kanban.effect.
styles?KanbanStylesStyles of the inner parts.
testID?stringTest id.

A label on a card (e.g. "Bug", "Frontend").

type KanbanTag = Core.KanbanTag<ReactNode>

A person assigned to a card; shown with AvatarGroup.

NameTypeDescription
namestringPerson's name; initials and tooltip are generated from it.
src?stringPhoto URL.

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

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

A column (stage) of the Kanban board.

type KanbanColumn = Core.KanbanColumn<ReactNode, IconProp>

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

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