@caldwell619/react-kanban

中文文档
0.0.12发布于 2025/02/04MITCommonJS零依赖近 30 天下载 1.5万

(fork of) Yet another Kanban/Trello board lib for React

原始使用文档
文档目录16 节
  1. asseinfo's React Kanban
  2. Why fork?
  3. Road Map
  4. Demo
  5. Setup
  6. Usage
  7. Uncontrolled
  8. Controlled
  9. Board
  10. Helpers to work with the controlled board
  11. Board type
  12. Props
  13. Styling
  14. Usage with Remix
  15. Contributing
  16. Steps

caldwell619 React Kanban

NPM NPM

asseinfo's React Kanban

Forked from asseinfo's React Kanban

Shout out to all the contributors.

Leandro Lourenci
Leandro Lourenci

💬 🐛 💻 📖 💡 ⚠️
Gleb Bahmutov
Gleb Bahmutov

⚠️
Matheus Sabino
Matheus Sabino

💻 📖 ⚠️
Pedro Javier Nicolás
Pedro Javier Nicolás

💻
Matheus Poli
Matheus Poli

💻 ⚠️ 📖
Carlinhos de Sousa Junior
Carlinhos de Sousa Junior

💻 ⚠️
Pete Duncanson
Pete Duncanson

💻 📖 💡

Why fork?

  • The original library seems to not be maintained anymore. The last commit at this time is September of 2021.
  • The original library did not include TypeScript types. It was written in JS without providing any types. This fork is natively written in TypeScript.

Road Map

Here is what's in the queue. If you want to see something, make an issue

Demo

Link

Setup

yarn add @caldwell619/react-kanban

You will also need to install the peer dependencies on your own:

  "peerDependencies": {
    "react": ">=16",
    "react-dom": ">=16",
    "@hello-pangea/dnd": ">=16"
  },

These are listed as peer dependencies because I do not want to pin specific versions as dependencies if you are already using them.

Usage

There are 2 main boards, Controlled and Uncontrolled.

This is a deviation from the original, as there was only one board exported. In the original, there's an in-library determination on whether or not the board is controlled. That is not quite how this works, as you will know upfront whether or not your board is controlled.

With that in mind, you can import each of the boards like this:

import { UncontrolledBoard, KanbanBoard } from '@caldwell619/react-kanban'
// import { ControlledBoard } from '@caldwell619/react-kanban'
import '@caldwell619/react-kanban/dist/styles.css' // import here for "builtin" styles

const board: KanbanBoard = {
  columns: [
    {
      id: 1,
      title: 'Backlog',
      cards: [
        {
          id: 1,
          title: 'Add card',
          description: 'Add capability to add a card in a column'
        },
      ]
    },
    { ... }
  ]
}

<UncontrolledBoard initialBoard={board} />

Uncontrolled

With an uncontrolled board, you pass an initialBoard prop, which will be the basis of the internal state. When a user moves something, that is all controlled by internal state.

Controlled

When you need a better control over the board, you should stick with the controlled board. A controlled board means you need to deal with the board state yourself, you need to keep the state in your hands (component) and pass this state to the <Board />, we just reflect this state.

If you go with the controlled one, you need to pass your board through the children prop.

Board

If you really want to use the one unified board, you can still do so with Board. Whether or not you provide initialBoard or children will determine which board you're using. If you provide both, UncontrolledBoard takes priority.

See an example, here.

Helpers to work with the controlled board

Helpers are exposed to help with the management of your board state when using the ControlledBoard. They are the same helpers used internally, so you can utilize them to assist in your controlled state.

import { ControlledBoard, moveCard, KanbanBoard, OnDragEndNotification, Card } from '@caldwell619/react-kanban'

const MyBoard = () => {
  const [board, setBoard] = useState<KanbanBoard>(initialBoard)

  const handleCardMove: OnDragEndNotification<Card> = (_card, source, destination) => {
    setBoard((currentBoard) => {
      return moveCard(currentBoard, source, destination)
    })
  }

  return <ControlledBoard onCardDragEnd={handleCardMove}>{board}</ControlledBoard>
}

Full list of helpers.

Board type

If you're using JS, this section doesn't have any effect on you.

The TypeScript type for the board is KanbanBoard. It is a generic that accepts TCard extends Card. Your data will undoubtedly need to be customized, so all the helpers and Board will accept your TCard.

import { Card } from '@caldwell619/react-kanban'

interface CustomCard extends Card {
  storyPoints: number
}
export const renderCard: UncontrolledBoardProps<CustomCard>['renderCard'] = (card) => {
  // Can access with `card.storyPoints`
  return <CardWithStoryPoints {...card} />
}

This behavior will applied throughout the render and confirm methods.

import { ControlledBoard, KanbanBoard } from '@caldwell619/react-kanban'

const CustomBoard = () => {
  return (
    <ControlledBoard<CustomCard>
      renderCard={(card) => {
        // `card.storyPoints`
        return <CardWithStoryPoints {...card} />
      }}
    >
      {board}
    </ControlledBoard>
  )
}

Props

For an exhaustive ( yet still WIP ) list of props you can pass, refer to this page.

Styling

You can either style all the board or import our style and override it with the styles you want. Ideally you would render the column instead of overriding CSS, however this may be helpful for you if your use case needs it.

Class
react-kanban-board
react-kanban-card
react-kanban-card-skeleton
react-kanban-card--dragging
react-kanban-card__description
react-kanban-card__title
react-kanban-column
react-kanban-card-adder-form
react-kanban-card-adder-button
react-kanban-card-adder-form__title
react-kanban-card-adder-form__description
react-kanban-card-adder-form__button
react-kanban-column-header
react-kanban-column-header__button
react-kanban-column-adder-button

Usage with Remix

Shout out to @vjanssens for discovering there are some extra steps for compatibility with Remix.

Add the following to your Vite config:

export default defineConfig({
  // the rest of your config
  ssr: {
    noExternal: ["@caldwell619/react-kanban"]
  },
});

Contributing

PRs are welcome.

Steps

  • File an issue, using the issue template.
  • Fork this project.
  • Clone your fork
  • In your fork, run yarn to install deps
  • Begin work
  • Add yourself to the contributors table, this is powered by all-contributors
    • yarn all-contributors add
    • yarn all-contributors generate
  • Submit your PR across forks with the target base as christopher-caldwell:master.

版本与发布记录

@caldwell619/react-kanban 共发布 12 个版本,首次发布于 2022/10/03;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.12latest2025/02/041.8 年前
0.0.112023/12/232 年前
0.0.102023/12/012 年前
0.0.92023/12/012 年前
0.0.82022/11/024 年前
0.0.72022/11/024 年前

关于 @caldwell619/react-kanban 的常见问题

@caldwell619/react-kanban 是什么?

(fork of) Yet another Kanban/Trello board lib for React

如何安装 @caldwell619/react-kanban?

在项目目录运行 npm install @caldwell619/react-kanban,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16)、react-dom(>=16)、@hello-pangea/dnd(>=16)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@caldwell619/react-kanban 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/caldwell619__react-kanban 是否存在。

@caldwell619/react-kanban 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@caldwell619/react-kanban 可以商用吗?

@caldwell619/react-kanban 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@caldwell619/react-kanban 的下载量有多少?

根据 npm 官方下载统计,@caldwell619/react-kanban 在 2026/10/09 – 2026/11/07 这 30 天内被下载 14,996 次,日均约 500 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@caldwell619/react-kanban 还在维护吗?

最新版本 0.0.12 发布于 2025/02/04(1.8 年前);至今共发布 12 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/10/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。