Kanban

Kanban is a task board. Cards are dragged within a column and from a column to another one, with the mouse, a finger or the keyboard, with work in progress limits, drop rules, collapsible and reorderable columns, and every move announced to screen readers.

import { Kanban } from '@exhaustive-ui/core/kanban';

Kanban displays columns, each with an id, a title and its items. Drag a card to reorder it in its column or to move it to another column, with the mouse, a finger or the keyboard. The board updates columns with new arrays after every move, so bind it two-way with [(columns)]. dataKey names the field that identifies a card, and itemLabel the field displayed by the default card, title by default.

To do3 cards
Write the release notes
Update the screenshots
Answer the support tickets
In progress2 cards
Fix the login redirect
Translate the onboarding
Review1 cards
Dark mode for the settings page
Done1 cards
Set up the staging server
Press Space or Enter to pick up the card. While it is picked up, the arrow keys move it, Space or Enter drops it and Escape cancels the move.

The card template replaces the content of a card and receives the card as the implicit variable, with its column, its index and a grabbed flag, true while the card is picked up with the keyboard. The columnHeader template replaces the title and the count of a column, columnFooter adds content at its bottom and empty replaces the message of an empty column; they receive the column, its count, its limit and an overLimit flag.

A card is a button that picks up the card: keep the content of the template static, without links or buttons, and open the details of a card with onCardClick.

Backlog2
EX-101Low
Export the report as CSV
reports
Amy Elsner
EX-102Medium
Remember the last opened tab
ux
Asiya Javayant
In progress1
EX-98High
Payment fails with 3-D Secure
bugbilling
Onyama Limba
Review0
Drop an issue here
Done1
EX-90Medium
Upgrade to Angular 22
chore
Ioni Bowcher
Press Space or Enter to pick up the card. While it is picked up, the arrow keys move it, Space or Enter drops it and Escape cancels the move.

The limit of a column is its work in progress limit: the header shows the count as "2 / 3", the count turns orange when the column is full and red when it holds more cards than its limit, and the column refuses the cards dropped beyond it. While a card is dragged over a column that refuses it, the column gets a dashed red border and screen readers hear the reason. A disabled column neither gives nor takes cards.

canDrop decides any other rule. It receives the card, the column it comes from and the column it would go to, and returns false to refuse the move; moves within a column are always allowed. Here a card can only reach Done from Review, and the Archived column is disabled.

To do3 cards
Plan the sprint
Interview a customer
Clean the backlog
In progress2 of 3 cards
New pricing page
Invoice emails
Review1 of 1 cards
Search filters
Done0 cards
No cards
Archived1 cards
Old landing page
Press Space or Enter to pick up the card. While it is picked up, the arrow keys move it, Space or Enter drops it and Escape cancels the move.

showAddButton adds an "Add card" button at the bottom of every column. It emits onAddCard with the column, and the application creates the card, often after a dialog; set the new columns to display it. The button is disabled in a disabled column and in a column that reached its limit.

Ideas1 cards
A mobile app
Planned2 of 2 cards
Two-factor authentication
Public API
Shipped0 cards
No cards
Press Space or Enter to pick up the card. While it is picked up, the arrow keys move it, Space or Enter drops it and Escape cancels the move.

collapsible adds a button to the header of every column that folds it into a narrow strip, as tall as the board, with its count and its title written vertically. A click anywhere on the strip unfolds it, and its button stays the way to do it with the keyboard. The board sets the collapsed property of the column and emits onColumnToggle; set collapsed in the columns to start with a folded column. A collapsed column does not take dropped cards, and the keyboard moves skip it.

Backlog3 cards
To do2 cards
Onboarding checklist
Export to PDF
In progress1 of 3 cards
Usage based billing
Done1 cards
Press Space or Enter to pick up the card. While it is picked up, the arrow keys move it, Space or Enter drops it and Escape cancels the move.

reorderColumns adds a drag handle to the header of every column. Drag it to move the column, or focus it and use Space or Enter, the left and right arrow keys, and Space or Enter again. The board emits onColumnReorder with the column, its previous and its new index once the columns are updated.

To do1 cards
Draft the newsletter
In progress1 cards
Record the demo video
Blocked1 cards
Legal review of the terms
Done0 cards
No cards
Press Space or Enter to pick up the card. While it is picked up, the arrow keys move it, Space or Enter drops it and Escape cancels the move.Press Space or Enter to pick up the column. While it is picked up, the left and right arrow keys move it, Space or Enter drops it and Escape cancels the move.

Order: To do, In progress, Blocked, Done

When the columns do not fit, they shrink to their minimum width, then the board scrolls horizontally, with a thin scrollbar, and fades out the edges that hide columns. scrollHeight gives the board a height: the cards of each column then scroll under its header, which stays visible. While a card is dragged near an edge, the board and the column scroll. On small screens a column takes most of the width and the board snaps from a column to the next one.

Backlog12 cards
Story 1
Story 2
Story 3
Story 4
Story 5
Story 6
Story 7
Story 8
Story 9
Story 10
Story 11
Story 12
To do6 cards
Task 1
Task 2
Task 3
Task 4
Task 5
Task 6
In progress3 cards
Feature 1
Feature 2
Feature 3
Review2 cards
Change 1
Change 2
QA2 cards
Test 1
Test 2
Done9 cards
Release 1
Release 2
Release 3
Release 4
Release 5
Release 6
Release 7
Release 8
Release 9
Press Space or Enter to pick up the card. While it is picked up, the arrow keys move it, Space or Enter drops it and Escape cancels the move.

onCardMove is emitted once a card is dropped, with the pointer or the keyboard, after the columns are updated. It holds the item, the fromColumn and toColumn as they are after the move, the fromIndex and toIndex, and all the columns: send the change to the server from there. A keyboard move only emits when the card is dropped, not at every arrow key, and Escape emits nothing.

To do2 cards
Order the new laptops
Book the team offsite
In progress1 cards
Hire a designer
Done0 cards
No cards
Press Space or Enter to pick up the card. While it is picked up, the arrow keys move it, Space or Enter drops it and Escape cancels the move.
  • Move a card to see the request.

With a server, keep the previous columns to put the card back when the request fails.

private http = inject(HttpClient);

columns = signal<KanbanColumn<Task>[]>(columnsFromTheServer);
private saved = this.columns();

onCardMove({ item, toColumn, toIndex, columns }: KanbanCardMoveEvent<Task>) {
    const previous = this.saved;
    this.http.patch(`/api/tasks/${item.id}`, { status: toColumn.id, position: toIndex }).subscribe({
        next: () => (this.saved = columns),
        error: () => this.columns.set(previous)
    });
}

Screen Reader

Every column is a group named by its title, rather than a landmark, so that two boards on a page never repeat landmarks such as "To do". It holds a list whose label also gives the count, such as "In progress, 2 of 3 cards", or a group with the same label when the column is empty. Each card is a list item holding a focusable element with the button role, described with aria-describedby by the instructions to move it, and with aria-pressed true while it is picked up. The count of a column reads "2 of 3 cards" instead of "2 / 3", and "over the limit" when it is exceeded.

A card can be moved with the keyboard alone, and an assertive live region announces each step: "Picked up Task A, position 2 of 5 in To do", "Moved to In progress, position 1 of 3", "Dropped Task A in In progress, position 1 of 3" or "Cancelled, Task A returned to To do, position 2 of 5". A refused move is announced with its reason, such as "Review is full, 1 of 1 cards", and so is a full column a card is dragged over with the pointer. The column drag handles, the collapse buttons and the add card buttons name their column, for example "Add card to Done". Name the board with ariaLabel or ariaLabelledBy, and translate every text with labels.

<h2 id="sprint">Sprint 42</h2>
<p-kanban [(columns)]="columns" ariaLabelledBy="sprint" [labels]="{ addCard: 'Ajouter une carte', empty: 'Aucune carte' }" />

Card Keyboard Support

KeyFunction
tabMoves focus to the next card, column button or add card button. Leaving a picked up card cancels its move.
space / enterPicks up the focused card, or drops the picked up card where it is.
up arrow / down arrowMoves the picked up card one position up or down in its column. Without a picked up card, moves focus to the previous or next card.
left arrow / right arrow Moves the picked up card to the previous or next column, skipping collapsed columns, unless the column refuses it. Without a picked up card, moves focus to the card at the same position in the previous or next column. Reversed in right-to-left layouts.
home / endMoves the picked up card to the top or the bottom of its column.
escapeCancels the move and puts the card back where it was.

Column Handle Keyboard Support

KeyFunction
space / enterPicks up the column, or drops the picked up column where it is.
left arrow / right arrowMoves the picked up column one position to the left or the right.
home / endMoves the picked up column to the first or the last position.
escapeCancels the move and puts the column back where it was.

The changes are only emitted when the card or the column is dropped, so a cancelled keyboard move never reaches onCardMove or onColumnReorder.