diff --git a/docs/app/components/content/examples/tree/TreeDragAndDropExample.vue b/docs/app/components/content/examples/tree/TreeDragAndDropExample.vue new file mode 100644 index 0000000000..e543701812 --- /dev/null +++ b/docs/app/components/content/examples/tree/TreeDragAndDropExample.vue @@ -0,0 +1,69 @@ + + + diff --git a/docs/content/docs/2.components/tree.md b/docs/content/docs/2.components/tree.md index 562c1b1169..7f3c4eacf0 100644 --- a/docs/content/docs/2.components/tree.md +++ b/docs/content/docs/2.components/tree.md @@ -518,6 +518,20 @@ props: This example uses the `as` prop to change the items from `button` to `div` as the [`Checkbox`](/docs/components/checkbox) is also rendered as a `button`. :: +### With drag and drop :badge{label="Soon"} + +Use the [`useSortable`](https://vueuse.org/integrations/useSortable/) composable from [`@vueuse/integrations`](https://vueuse.org/integrations/README.html) to enable drag and drop functionality on the Tree. This integration wraps [Sortable.js](https://sortablejs.github.io/Sortable/) to provide a seamless drag and drop experience. + +::component-example +--- +name: 'tree-drag-and-drop-example' +--- +:: + +::note +This example sets the `nested` prop to `false` to have a flat list of items so that the items can be dragged and dropped. +:: + ### With virtualization :badge{label="Soon"} Use the `virtualize` prop to enable virtualization for large lists as a boolean or an object with options like `{ estimateSize: 32, overscan: 12 }`. diff --git a/src/runtime/components/Tree.vue b/src/runtime/components/Tree.vue index 6b52f7f657..af884121e1 100644 --- a/src/runtime/components/Tree.vue +++ b/src/runtime/components/Tree.vue @@ -139,7 +139,8 @@ export type TreeSlots< @@ -343,6 +350,7 @@ const defaultExpanded = computed(() =>