You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/core/use-drag-container.md
+100Lines changed: 100 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,100 @@ const result = useDragContainer();
12
12
13
13
The `useDragContainer` composable doesn't accept any parameters.
14
14
15
+
### Props Support
16
+
17
+
The drag container component can accept props using `defineProps()`. This allows you to pass custom data and configuration to your container component:
18
+
19
+
```vue
20
+
<script setup lang="ts">
21
+
import { useDragContainer } from '@vue-dnd-kit/core';
You can access container props within your dragged elements by passing them through the `containerProps` option in `useDraggable`:
93
+
94
+
```vue
95
+
<script setup lang="ts">
96
+
import { useDraggable } from '@vue-dnd-kit/core';
97
+
98
+
const { elementRef } = useDraggable({
99
+
id: 'my-draggable',
100
+
containerProps: {
101
+
theme: 'dark',
102
+
animation: 'fade',
103
+
customData: { userId: 123 },
104
+
},
105
+
});
106
+
</script>
107
+
```
108
+
15
109
### Return Value
16
110
17
111
`useDragContainer` returns an object with the following properties:
@@ -53,3 +147,9 @@ The `pointerPosition` object includes:
53
147
8. For performance reasons, apply `will-change: transform` to elements that will move during dragging.
54
148
55
149
9. You may want to conditionally show the container only when `isDragging` is true to improve performance.
150
+
151
+
10.**Props Support**: Container components can accept props using `defineProps()` and access them within the component template and logic.
152
+
153
+
11.**Container Props**: Use the `containerProps` option in `useDraggable` to pass custom data to your container component.
154
+
155
+
12.**Reactive Props**: When passing reactive values (ref, reactive, computed), pass them directly without calling `.value`. Vue will automatically track reactivity.
| moveStep |`number`| Pixels to move when using keyboard navigation |
60
61
62
+
### Container Props
63
+
64
+
The `containerProps` option allows you to pass custom data and configuration to your drag container component. This is useful for customizing the appearance and behavior of the container during drag operations:
**Important**: When passing reactive values (ref, reactive, computed), pass them directly without calling `.value`. Vue will automatically track reactivity.
100
+
61
101
### Return Value
62
102
63
103
`useDraggable` returns an object with the following properties:
This ensures Vue correctly tracks dependencies and updates the draggable behavior when your reactive values change.
272
+
273
+
8.**Container Props**: Use the `containerProps` option to pass custom data and configuration to your drag container component. This allows for dynamic customization of the container during drag operations.
0 commit comments