Kanban
<zn-kanban>
ZnKanban
A board of columns whose cards can be dragged from one column to another.
A board is a row of zn-kanban-column elements, each holding zn-kanban-item cards.
Drag a card to move it within its column or into another one. While dragging, the other columns outline
where the card can go; Escape, or letting go outside the board, puts it back. Columns count their own cards
and show an empty state when they have none. When the columns don’t fit, the row scrolls sideways and fades
at each edge that has more columns past it.
<zn-kanban id="kanban-preview"> <zn-kanban-column value="lead" caption="Lead" meta="£1.4m" description="First contact made"> <zn-kanban-item value="tidewater"> <strong>Tidewater Streaming</strong> <span>£820k / month · Stripe</span> <zn-badge type="warning">6 days in stage</zn-badge> </zn-kanban-item> <zn-kanban-item value="harbour"> <strong>Harbour & Pine</strong> <span>£580k / month · Adyen</span> </zn-kanban-item> </zn-kanban-column> <zn-kanban-column value="qualified" caption="Qualified" meta="£2.1m" description="Volume and PSP confirmed"> <zn-kanban-item value="northwind"> <strong>Northwind Games</strong> <span>£2.1m / month · Checkout.com</span> </zn-kanban-item> </zn-kanban-column> <zn-kanban-column value="proposal" caption="Proposal" description="Pricing sent"></zn-kanban-column> <zn-kanban-column value="won" caption="Won" description="Contract signed"></zn-kanban-column> </zn-kanban>
Examples
Listening for moves
zn-move fires when a card is dropped somewhere new. Its detail holds the
item, the column it came from, the column it went to and its new
index in that column. Cancel the event to put the card back.
<zn-kanban id="kanban-move"> <zn-kanban-column value="todo" caption="To do"> <zn-kanban-item value="a">Write proposal</zn-kanban-item> <zn-kanban-item value="b">Book kickoff</zn-kanban-item> </zn-kanban-column> <zn-kanban-column value="doing" caption="Doing"></zn-kanban-column> <zn-kanban-column value="done" caption="Done" empty-text="Drop finished work here"></zn-kanban-column> </zn-kanban> <script> document.querySelector('#kanban-move').addEventListener('zn-move', e => { const {item, from, to, index} = e.detail; console.log(`${item.value}: ${from.value} → ${to.value} at ${index}`); }); </script>
Column actions
Anything in a column’s actions slot sits at the end of its header.
<zn-kanban> <zn-kanban-column caption="Backlog"> <zn-button slot="actions" icon="add" color="transparent" size="x-small" title="Add card"></zn-button> <zn-kanban-item>Audit checkout flow</zn-kanban-item> </zn-kanban-column> <zn-kanban-column caption="In review"></zn-kanban-column> </zn-kanban>
Column width
Columns share the board’s width between --zn-kanban-column-min-width (default
18rem) and --zn-kanban-column-max-width (default 22rem); once they
don’t fit, the row scrolls sideways. --zn-kanban-column-min-height keeps short columns tall
enough to drop into.
<zn-kanban style="--zn-kanban-column-min-width: 22rem; --zn-kanban-column-min-height: 10rem"> <zn-kanban-column caption="Wide"> <zn-kanban-item>A wider card with room for more detail.</zn-kanban-item> </zn-kanban-column> <zn-kanban-column caption="Columns"></zn-kanban-column> </zn-kanban>
Columns
| Attribute | Description |
|---|---|
value |
Identifies the column in zn-move events. |
caption |
The column’s title. |
meta |
Secondary text at the end of the header, such as a column total. |
description |
A line under the header, such as the rule for entering the column. |
empty-text |
Shown when the column has no cards. Defaults to “Nothing here”. |
Items
zn-kanban-item is a card with a default slot for its content. Its value identifies
it in zn-move events.
Importing
If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.
To import this component from the CDN using a script tag:
<script type="module" src="https://cdn.jsdelivr.net/npm/@kubex/zinc@2.0.45/dist/components/kanban/kanban.js"></script>
To import this component from the CDN using a JavaScript import:
import 'https://cdn.jsdelivr.net/npm/@kubex/zinc@2.0.45/dist/components/kanban/kanban.js';
To import this component using a bundler:
import '@kubex/zinc/dist/components/kanban/kanban.js';
Slots
| Name | Description |
|---|---|
| (default) | The board’s zn-kanban-column elements. |
Learn more about using slots.
Events
| Name | React Event | Description | Event Detail |
|---|---|---|---|
zn-move |
|
Emitted when a card is dropped in a new place. Cancel it to put the card back. |
{item: ZnKanbanItem, from: ZnKanbanColumn, to: ZnKanbanColumn, index: number}
|
Learn more about events.
Custom Properties
| Name | Description | Default |
|---|---|---|
--zn-kanban-column-min-width |
The narrowest a column gets; the row scrolls sideways once they don’t fit. | |
--zn-kanban-column-max-width |
The widest a column grows to fill the board. | |
--zn-kanban-column-min-height |
The minimum height of each column, so empty ones stay easy to drop on. |
Learn more about customizing CSS custom properties.
Parts
| Name | Description |
|---|---|
base |
The scrolling row of columns. |
Learn more about customizing CSS parts.
Dependencies
This component automatically imports the following dependencies.
<zn-kanban-column><zn-kanban-item>