Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
Editors and workspaces

useKanban

Provides controlled Kanban move requests and accessible props for boards, columns, items, and dedicated drag handles across keyboard, mouse, and touch input.

Live component preview · Astro

Explore KanbanBoard

Try the component this hook connects to. The preview uses the Astro adapter; the React example below uses useKanban.

Planned

Release notesDocs

In progress

Released

React usage

Import from @santi020k/lumen-react and spread the controller props onto the matching components.

tsxuseKanban example
import { Button, Card, KanbanBoard, KanbanColumn, useKanban } from '@santi020k/lumen-react'

export function EditorialBoard() {
  const kanban = useKanban({
    onMoveRequest: ({ itemId, toColumn }) =>
      console.log(`Move ${itemId} to ${toColumn}`)
  })

  return (
    <KanbanBoard {...kanban.rootProps} aria-label="Editorial workflow">
      <KanbanColumn value="planned" {...kanban.getColumnProps('planned')}>
        <Card as="article" {...kanban.getItemProps('draft')}>
          <Button {...kanban.getHandleProps('draft')} aria-label="Move Draft article">
            Move
          </Button>
          <strong>Draft article</strong>
        </Card>
      </KanbanColumn>
      <KanbanColumn value="published" {...kanban.getColumnProps('published')} />
    </KanbanBoard>
  )
}
import { Button, Card, KanbanBoard, KanbanColumn, useKanban } from '@santi020k/lumen-react'

export function EditorialBoard() {
  const kanban = useKanban({
    onMoveRequest: ({ itemId, toColumn }) =>
      console.log(`Move ${itemId} to ${toColumn}`)
  })

  return (
    <KanbanBoard {...kanban.rootProps} aria-label="Editorial workflow">
      <KanbanColumn value="planned" {...kanban.getColumnProps('planned')}>
        <Card as="article" {...kanban.getItemProps('draft')}>
          <Button {...kanban.getHandleProps('draft')} aria-label="Move Draft article">
            Move
          </Button>
          <strong>Draft article</strong>
        </Card>
      </KanbanColumn>
      <KanbanColumn value="published" {...kanban.getColumnProps('published')} />
    </KanbanBoard>
  )
}

Load @santi020k/lumen-react/styles.css once in your application. With React Server Components, put 'use client' at the top of the module that calls the hook. Follow the React setup guide for the framework boundary.

Options

PropertyTypeDefaultDescription
onMoveRequest(detail: LumenKanbanMoveDetail) => void-Receives an accepted move request; the application remains responsible for updating and persisting item ownership.

Controller return values

PropertyTypeDescription
rootPropsLumenProps<"section">Spread onto the Kanban board root.
getColumnProps(column, props?) => LumenProps<"section">Returns drop-target props for a named column.
getItemProps(itemId, props?) => LumenProps<"article">Returns identity props for a controlled item.
getHandleProps(itemId, props?) => LumenProps<"button">Returns keyboard, pointer, and drag props for an item move handle.
requestMove(detail: LumenKanbanMoveDetail) => booleanDispatches a cancelable ui:kanban-move-request event and reports whether it was accepted.
rootRefRefObject<HTMLElement | null>Ref for the board element used to resolve items and destinations.
Web docsFull catalog