Skip to content

Drag 拖拽组件

TIP

  • 基于 HTML5 原生 DnD,零依赖
  • 支持插入位置指示器
  • 支持选中态、复制、删除操作
  • 支持跨容器拖入(accept 配置)

基本排序

卡片式 + 复制删除

跨容器拖入

API

属性名描述类型默认值是否必需
items数据配置项DragItemData[][]
onChange列表变化后的回调(list: DragItemData[]) => void-
onDrop拖拽排序完成的回调(fromIndex: number, toIndex: number) => void-
onSelected选中 item 的回调(item: DragItemData | null) => void-
defaultKey默认选中的 item keystring | number-
selected是否可以选中booleantrue
showDashedLine是否显示虚线边框高亮booleantrue
direction排列与拖拽检测方向'vertical' | 'horizontal''vertical'
style容器行内样式CSSProperties-
accept是否接受外部容器拖入的 itembooleantrue
dragId容器唯一 ID(跨容器用)string自动生成
children传入 children 时直接渲染(不走 items 逻辑)ReactNode-