Skip to content

shadcn.io is an independent project built on shadcn/ui

Components

Free

Kanban for Ark UI

Columns of cards people move by mouse, touch or keyboard. A kanban board for React and Ark UI with its own drag code and announced moves.

On this page9 sections

A kanban board lays work out in columns, one per stage, and people move each card along by dragging it or with the keyboard. Reach for it when work passes through a few fixed stages and people move it themselves: a sprint, a hiring pipeline, a content calendar. The board handles the pointer and the keys in its own code, so it adds no drag-and-drop package.

Records people sort and compare belong in a Table. For one column of grouped rows in a narrow panel, use a List.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Kanban anatomy: provider, board, header, cards, card

Usage

import { useState } from "react";
import {
  KanbanBoard, KanbanCard, KanbanCards, KanbanHeader, KanbanProvider,
} from "@/components/ui/kanban";
const columns = [
  { id: "todo", name: "To Do" },
  { id: "done", name: "Done" },
];

const Board = () => {
  const [tasks, setTasks] = useState([
    { column: "todo", id: "1", name: "Write the release notes" },
    { column: "done", id: "2", name: "Rotate the API keys" },
  ]);

  return (
    <KanbanProvider columns={columns} onValueChange={setTasks} value={tasks}>
      {columns.map((column) => (
        <KanbanBoard id={column.id} key={column.id}>
          <KanbanHeader>{column.name}</KanbanHeader>
          <KanbanCards>
            {tasks
              .filter((task) => task.column === column.id)
              .map((task) => (
                <KanbanCard id={task.id} key={task.id} name={task.name} />
              ))}
          </KanbanCards>
        </KanbanBoard>
      ))}
    </KanbanProvider>
  );
};

The items are one flat array. Each has an id, a name and the column it sits in, and their order in the array is their order within each column. A move hands the whole new array to onValueChange, and the board shows only what value holds.

Accessibility

Each card is a tab stop with the button role, described as a draggable card, and its aria-describedby points at a hidden line that explains the keys. A card lifted from the keyboard reports aria-pressed as true, and once focus leaves it, by Tab or a click elsewhere, it drops where it is. Each column is a group labeled with its name. A polite live region announces each pick-up, step, drop and cancel, such as "Dropped Rotate the API keys in Done, position 2 of 3". What stays with you: give every item a name that reads well aloud, since the announcements use it, and translate the English sentences in components/ui/kanban if your app isn't in English.

Space
On a card, picks it up. On a card you are holding, drops it where it is.
Enter
On a card, picks it up. On a card you are holding, drops it where it is.
Arrow Up
Moves the held card up one place in its column.
Arrow Down
Moves the held card down one place in its column.
Arrow Left
Moves the held card to the previous column, or to the next one in a right-to-left layout, keeping its position where the column has room.
Arrow Right
Moves the held card to the next column, or to the previous one in a right-to-left layout, keeping its position where the column has room.
Home
Moves the held card to the top of its column.
End
Moves the held card to the bottom of its column.
Escape
Cancels the move and puts the card back where it was picked up, during a mouse drag as well.
Tab
Drops the held card where it is and moves focus on. With no card held, moves focus as usual.

Demos

Custom cards

A product roadmap in Planned, Building and Shipped, where each card shows a feature, its date range, its owner's avatar and a Badge for its area, and each header has a colored dot and a count. KanbanCard renders its children in place of its name. Pick this when people need the owner or the dates to decide where a card goes, and keep longer details off the board.

Preview width

Move events

Four tasks across To Do, Doing and Done, with a line under the board that prints what onMoveStart and onMoveEnd report: the card, where it came from, and where it went to, or that it went back when the move was cancelled. Both fire for a drag and for the keyboard. Save or log a move from the end event, since it fires once when the move is over.

Preview width

Scrolling

Twelve bug reports, eight in Inbox and four in Triaged, on a board fixed at h-80. The columns stretch to that height and their cards scroll inside them, so a long Inbox doesn't push the page down. Drag a card near a column's top or bottom edge and the column scrolls under it, and where the four columns don't fit, the board's side edges scroll it sideways the same way.

Preview width

FAQ

What data does the Kanban board need?

Two arrays. columns lists each column's id and name in the order they appear, and value lists every card with its own id, a name and the column id it belongs to.

There is no index field: a card's position in its column is its order in that one array, so render each column by filtering the array without sorting it. Items can carry fields of their own, such as an owner or a due date. A move keeps them and changes only column and the order.

How do I save where a Kanban card was moved in React?

Save from onMoveEnd, which fires once per finished move with the card's id, where it came from and where it went to, each a column id and a 0-based index. When the move is cancelled, or the card is dropped outside the board, to is null. Keep onValueChange for your state: it fires on every arrow-key step and again when Escape restores the board, so sending it to a server would save moves nobody finished.

The board keeps no copy of the items. If a dropped card jumps back, the new array isn't reaching value. The Move events demo prints both events.

Can people move Kanban cards without a mouse?

Yes. Tab to a card and press Space or Enter to pick it up. The up and down arrows move it within its column, left and right move it to the next column over, and Home and End send it to the top or bottom.

Press Space or Enter to drop it, or Escape to put it back where it started. A live region announces each step with the column and the position. The Accessibility section lists every key.

Does the Kanban board work on touch screens?

Yes. A finger held still on a card for a quarter of a second picks it up, and from then on the page stays put while the card follows the finger.

A finger that moves before then is treated as a scroll, so swiping through a long column or across the board still works on a phone. Dragging near a column's top or bottom edge scrolls that column, as it does with a mouse.

How do I make Kanban columns scroll instead of growing the page?

Give KanbanProvider a height class, such as h-80. Columns stretch to fill it, and each column's cards scroll inside it once they run past the bottom, as the Scrolling demo shows.

Without a height the columns grow with their cards, each at least 10rem tall. Columns are at least 11rem wide, and when they don't fit side by side, the board scrolls sideways.

How do I put more than a title on a Kanban card?

Pass children to KanbanCard. They replace the name, as in the Custom cards demo. The announcements still read the item's name from value, never the card's children, so keep it a short title.

A card has the button role, so a screen reader reads all of its text as one name, and an aria-label on the card shortens it.

A press that starts on a link, a button, a field or anything marked data-kanban-no-drag keeps its own click and doesn't start a drag. ARIA treats the children of a button as presentational, though, so keep real controls inside a card to a minimum.

How do I change how a dragged Kanban card looks?

Edit the classes in components/ui/kanban, where each state has its own data attribute. The card left in place while you drag gets data-held and fades, and the copy under the pointer is the kanban-card-overlay slot, tilted and ringed.

A card lifted from the keyboard gets data-lifted, and the column under a dragged card gets data-over. The thin line at the drop point is drawn by the card next to it, which gets data-drop set to before or after. Change these once and every board in the app follows.

Should I use Kanban or List?

Use Kanban when the stages sit side by side and people move work across them, which needs room for several columns. Use a List for one column of groups, such as tasks under To Do, In Progress and Done in a narrow side panel.

Both take a flat array of items and move them by pointer, touch or keyboard. The field that names an item's group differs, column here and status on a List, so switching later means renaming that field along with the parts.

API Reference

KanbanProvider

PropType
valueT[]

The items, in order. Render each column's cards from it.

onValueChange?(value: T[]) → void

Called with every item, in order, after each move. Set value from it.

Parameters

value – T[]

Returns
void
columnsKanbanColumnData[]

The columns, in order: a KanbanBoard for each. Arrow keys move a lifted card along them.

onMoveEnd?(details: KanbanMoveDetails) → void

Called when a card is dropped, or its move is cancelled (to is null).

Type
(details: KanbanMoveDetails) → void
Parameters

details – { from: KanbanSpot; id: string; to: KanbanSpot | null }

Returns
void
onMoveStart?(details: KanbanMoveDetails) → void

Called when a card is picked up, by the pointer or the keyboard.

Type
(details: KanbanMoveDetails) → void
Parameters

details – { from: KanbanSpot; id: string; to: KanbanSpot | null }

Returns
void
className?string

Merged with the part's classes.

KanbanBoard

<div> data-slot="kanban-board"

PropType
idstring

The id of the column this board shows.

className?string

Merged with the part's classes.

AttributeType
data-kanban-column?string

Mirrors id.

data-over?string

KanbanHeader

<div> data-slot="kanban-header"

PropType
className?string

Merged with the part's classes.

KanbanCards

<div> data-slot="kanban-cards"

PropType
className?string

Merged with the part's classes.

AttributeType
data-kanban-list""
Default
""

KanbanCard

data-slot="kanban-card"

PropType
idstring

The item's id.

namestring

The item's name: the card's content when it has no children.

className?string

Merged with the part's classes.

AttributeType
data-drop?string
data-held?string

Present when held is true.

data-kanban-card?string

Mirrors id.

data-lifted?string