Cómo funciona
The board is controlled: it shows a preview order while you drag and calls onChange once on drop. The floating copy is positioned in board coordinates divided by the board's scale, so it stays under the pointer inside zoomed or transformed containers. Every card that moves is animated with FLIP from where it was drawn, including mid-animation. Touch starts a drag after a 220ms press, so a quick swipe still scrolls the page. Below 560px of width the columns stack.
Úsalo para
- Moving work through stages: tasks, hiring pipelines, content calendars.
- Small to medium boards, up to a few dozen cards per column.
Busca otra opción cuando
- Reordering one list: use a sortable list.
- Hundreds of cards per column: add virtualisation or paging first.
Uso
import { useState } from 'react'
import { KanbanBoard } from './KanbanBoard.jsx'
const columns = [
{ id: 'todo', title: 'To do' },
{ id: 'doing', title: 'In progress', limit: 3 },
{ id: 'done', title: 'Done' },
]
export function Sprint() {
const [tasks, setTasks] = useState([
{ id: '1', column: 'todo', title: 'Pricing page hero' },
{ id: '2', column: 'doing', title: 'Image compression' },
])
return (
<KanbanBoard
columns={columns}
items={tasks}
onChange={(next, move) => setTasks(next)}
renderCard={(task) => <strong>{task.title}</strong>}
/>
)
}Propiedades
| Propiedad | Tipo | Por defecto | Qué hace |
|---|---|---|---|
columns | { id, title, color?, limit? }[] | — | The columns in order. limit shows count/limit and turns amber when exceeded (it does not block drops). |
items | { id, column, ... }[] | — | The cards; their order within a column is their order in this array. |
onChange | (items, { id, from, to, index }) => void | — | Called on drop with the reordered array (the moved card's column updated) and what moved. |
renderCard | (item) => ReactNode | — | Card content. The card shell, focus and drag handling come from the board; avoid buttons inside cards. |
getTitle | (item) => string | item.title | Name used in screen reader announcements. |
labels | object | — | Replaces built-in text and announcement functions: card, instructions, picked, moved, dropped, cancelled, empty. |
...rest | HTMLAttributes<HTMLDivElement> | — | Passed to the root. Floating card layer: --ds-kanban-z (40). |
Accesibilidad
- Each card is a focusable role="button" with aria-roledescription "draggable card" and instructions linked through aria-describedby.
- Keyboard: Space or Enter picks up, Up / Down move within a column, Left / Right move to the next column, Space or Enter drops, Escape cancels; focus follows the card.
- Every pick-up, move, drop and cancel is announced in a live region with the column and position.
- Columns are labelled sections and cards are list items, so counts are announced. Reduced motion removes the tilt, the lift and all sliding.
Movimiento
Lifting tilts the card 2deg and scales it to 1.03 on a 220ms spring. Neighbours slide out of the way in 260ms. On drop the card travels from the pointer to its slot on a 520ms spring (cubic-bezier(0.3, 1.4, 0.5, 1)), untilting as it lands.
Añádelo a tu proyecto
Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.
KanbanBoard.jsxkanban-board.csstokens.cssREADME.md
Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.





