<kanban-board>
Columnar drag-and-drop board with user-defined columns, count badges, and optional WIP limits.
Overview
A web component that renders a columnar drag-and-drop board with user-defined columns. Each column wraps a <drag-surface> for native drag-and-drop and keyboard-accessible reordering and transfer. Supports any draggable content — user-story cards, plain articles, or custom elements. Includes auto-updating count badges, optional WIP (work-in-progress) limits with visual warnings, and optional column color tinting.
<kanban-board> <section data-column="backlog" data-column-label="Backlog"> <user-story draggable="true" data-id="PROJ-201" story-id="PROJ-201" priority="high" status="to-do" points="5" detail="minimal"> <span slot="persona">Sarah Chen</span> <span slot="action">view all project timelines in one dashboard</span> </user-story> </section> <section data-column="in-progress" data-column-label="In Progress"> <user-story draggable="true" data-id="PROJ-198" story-id="PROJ-198" priority="high" status="in-progress" points="5" detail="minimal"> <span slot="persona">Jordan Park</span> <span slot="action">filter reports by date range and team</span> </user-story> </section> <section data-column="review" data-column-label="Review"> </section> <section data-column="done" data-column-label="Done" data-column-color="success"> </section></kanban-board>
Attributes
| Attribute | Values | Default | Description |
|---|---|---|---|
src | string | — | URL to JSON data for columns and items. Fetched once per value; a new value replaces the board and aborts an older in-flight request |
title | string | — | Optional heading above the board; also names the board region. Untitled boards are named "Kanban board", numbered from the second board on the page ("Kanban board 2") so region names stay unique |
compact | boolean | — | Reduced spacing variant |
heading-level | number | — | Level (1-6) of the board's top heading: the title when set, otherwise the column headings (which sit one level below a title). Default: one below the nearest heading before the board, so the outline never skips a level |
Child Attributes
Set these on <section> children to define columns:
| Attribute | On | Type | Description |
|---|---|---|---|
data-column | <section> | string | Column identifier (e.g. "backlog", "doing", "done") |
data-column-label | <section> | string | Display label for the column header. Falls back to title-cased data-column |
data-wip | <section> | number | Optional WIP limit. Visual warning when exceeded |
data-column-color | <section> | string | Color token for column tint: success, warning, error, info |
Set these on draggable children within sections:
| Attribute | Type | Description |
|---|---|---|
draggable="true" | boolean | Required for drag capability (auto-added if missing) |
data-id | string | Stable identifier for the item (auto-generated if missing) |
WIP Limits
Add data-wip to any column section to set a work-in-progress limit. When the number of items in a column exceeds the limit, the component adds a data-wip-exceeded attribute to the column and fires a kanban-board:wip-exceeded event. Items are not blocked from entering — this is a visual warning only.
<kanban-board> <section data-column="backlog" data-column-label="Backlog"> <article draggable="true" data-id="task-1">Task A</article> <article draggable="true" data-id="task-2">Task B</article> </section> <section data-column="doing" data-column-label="In Progress" data-wip="2"> <article draggable="true" data-id="task-3">Task C</article> <article draggable="true" data-id="task-4">Task D</article> </section> <section data-column="done" data-column-label="Done"> </section></kanban-board>
Generic Content
The board is not limited to sprint planning. Any draggable content works — blog posts through a publishing pipeline, support tickets, hiring candidates, or content workflows.
<kanban-board> <section data-column="ideas" data-column-label="Ideas" data-column-color="info"> <article draggable="true" data-id="post-1"> <strong>CSS Container Queries Deep Dive</strong> <small>Tutorial</small> </article> </section> <section data-column="drafting" data-column-label="Drafting" data-wip="2"> </section> <section data-column="published" data-column-label="Published" data-column-color="success"> </section></kanban-board>
Events
| Event | Detail | Description |
|---|---|---|
kanban-board:transfer | { itemId, fromColumn, toColumn, newIndex, item } | Item moved between columns |
kanban-board:reorder | { itemId, column, oldIndex, newIndex } | Item reordered within a column |
kanban-board:ready | { columnCount, itemCount } | Fired once after the first render. With src, fired once the JSON has loaded and rendered. Once per element: not re-fired by a later src change (watch items-changed with source 'src') or when the board is moved in the DOM |
kanban-board:wip-exceeded | { column, limit, count } | Fired when a drop takes a column over its WIP limit |
kanban-board:items-changed | { items, source: 'api' | 'drag' | 'src' } | Fired after the items array changes: an .items assignment, or a .columns assignment that drops cards (source 'api'), a drag (source 'drag'), or each src load once its data has rendered (source 'src'). Filter on source to avoid feedback loops |
kanban-board:upgraded | — | Fired (in a microtask) each time the board connects and upgrades; a safe signal for assigning .columns / .items from a framework |
Property API (JS-first)
Reactive frameworks (Montane, Lit, Solid, Vue, React, Svelte) can drive the board directly with property assignments — no need to template the column structure. Existing card nodes whose id is in both the previous and next list are preserved across diffs: in-flight drag state, focus, and CSS animations survive untouched.
| Property | Type | Description |
|---|---|---|
.columns | { id, label?, wip?, color? }[] | Replaces all columns and rebuilds the shell. Existing cards whose column is still present move (same DOM nodes) into the new columns; cards whose column is gone are removed from the board and from .items, and kanban-board:items-changed reports it. Setting an empty array clears the board. |
.items | { id, column, ... }[] | Setter runs a keyed diff. id is the key; column selects the target drag-surface. Other fields go to the renderer. |
.renderItem | (item) => Element | Optional custom item renderer. Default builds a <work-item> and applies fields via .data. |
const board = document.querySelector('kanban-board'); // Wait for the upgrade signal before assigning.if (!board.hasAttribute('data-upgraded')) await new Promise(r => board.addEventListener('kanban-board:upgraded', r, { once: true })); board.columns = [ { id: 'todo', label: 'To Do', wip: 5 }, { id: 'doing', label: 'In Progress', wip: 3, color: 'warning' }, { id: 'done', label: 'Done', color: 'success' },]; // Assigning .items diffs against current cards.board.items = [ { id: 'PROJ-1', column: 'todo', title: 'Wire auth', type: 'task', priority: 'high' }, { id: 'PROJ-2', column: 'doing', title: 'Refactor cache', type: 'feature', priority: 'medium' },]; // Avoid feedback loops by ignoring drag-sourced changes:board.addEventListener('kanban-board:items-changed', (e) => { if (e.detail.source === 'drag') updateMyState(e.detail.items);});
See the Data API concepts guide for the full design rationale, the diff algorithm's preservation guarantee, and how to migrate an imperative integration to the property API.
JSON Data Mode
Set the src attribute to load board data from a JSON URL. The URL is fetched once; kanban-board:ready fires after the data has rendered. Changing src loads the new URL and replaces the board (the request for an older URL is aborted). ready fires once per board; every src load that renders also fires kanban-board:items-changed with source: 'src', so listen for that to react to later loads. Moving the board in the DOM keeps the loaded cards and does not refetch.
Items with a storyId, persona, action, or benefit field are rendered as <user-story> cards: persona, action, and benefit become <span slot="…"> children, title an <h3 slot="title">, and storyId, priority, status, points, and detail (default minimal) the matching attributes. All other items are rendered as <article class="kb-card"> showing text (or label / title).
{ "columns": [ { "id": "backlog", "label": "Backlog", "wip": null, "color": null, "items": [ { "id": "task-1", "text": "Design review" }, { "id": "PROJ-201", "storyId": "PROJ-201", "persona": "Sarah Chen", "action": "view timelines", "priority": "high", "detail": "minimal" } ] } ]}
Keyboard Navigation
Card keyboard support comes from the underlying <drag-surface>. Each card is one tab stop:
- Tab moves between cards; Up / Down move focus within a column
- Space grabs the focused card (Enter does too, except on a minimal
<user-story>, see below) - While grabbed: Up / Down reorder within the column, Left / Right move the card to the previous / next column
- Space or Enter drops the card; Escape cancels and puts it back
A minimal <user-story> card (as in the demo above) keeps its own action: Enter opens its detail dialog and Space grabs it. A click opens the dialog too.
Accessibility
- The columns container has
role="region", labelled by thetitleattribute. An untitled board is "Kanban board", numbered from the second board on a page ("Kanban board 2") so region names stay unique; give each board atitlefor a meaningful name. - Headings follow the page outline: the title (when set) is one level below the nearest heading before the board, and the column headings one level below that — or one below the page heading when there is no title — so levels are never skipped. Set
heading-level(1–6) to choose the board's top level yourself. - Each drag-surface has an
aria-labelof the column label plus "items" (e.g. "Backlog items") - Each
<drag-surface>is exposed as a list of its cards (role="list"/"listitem", kept in step as cards are added and moved). If any card is an element that may not be a list item, such as<article>, that surface is exposed as a labelledrole="group"instead and the cards keep their own role. The drag-surface's own move announcements are moved to a hidden status region just after the list, since a list may only contain list items. - A visually hidden live region announces transfers between columns using the card's text and the column labels (e.g. "Wire auth moved from To Do to In Progress")
- Count badges use
<output>elements for live value updates - Respects
prefers-reduced-motion: reduce
Retrospective recipe
Start / Stop / Continue retrospective boards are just <kanban-board> with three named columns. The component already supports arbitrary data-column children — there's no separate retrospective-board component needed.
<kanban-board> <section data-column="start" data-column-label="Start" data-column-color="success"> <article class="retro-card" draggable="true" data-id="r-1">Pair-program on tricky migrations</article> </section> <section data-column="stop" data-column-label="Stop" data-column-color="warning"> <article class="retro-card" draggable="true" data-id="r-2">Skipping standup notes</article> </section> <section data-column="continue" data-column-label="Continue" data-column-color="info"> <article class="retro-card" draggable="true" data-id="r-3">Demo-driven dev review every Thursday</article> </section></kanban-board>
Related
<drag-surface>— the underlying drag-and-drop engine<story-map>— horizontal story map with activity columns<impact-effort>— 2×2 prioritization matrix<user-story>— Agile story cards to use as board items