Draggable

Pointer-, touch-, and keyboard-friendly drag-and-drop. Make any element draggable, group items into a sortable list, or drop items into a zone — the framework fires bubbling draggable:start, draggable:drag, and draggable:end events.

Basic Draggable

Add .vd-draggable to any element to make it draggable.

Drag me around
And me too
With Handle

Use .vd-draggable-handle so only the handle starts a drag — the rest of the element stays selectable.

Photo block
Text block
Sortable Container

Wrap items in .vd-draggable-container.vd-draggable-container-vertical to reorder them by dragging.

First item
Second item
Third item
Fourth item
Drop Zone

Drag the item below into the .vd-drop-zone. Empty zones show a placeholder and highlight while you drag over them.

Drag me into the zone
Disabled State

Add .is-disabled to lock an item in place.

Draggable
Disabled (can't move)
Engine wiring
API Reference

Classes & Attributes

Class / AttributeDescription
.vd-draggableMakes an element draggable (pointer + touch + keyboard).
data-draggable="id"Stable id carried on the draggable lifecycle events.
.vd-draggable-handleOptional grab handle — only the handle starts a drag.
.vd-draggable-containerWraps items into a sortable group.
.vd-draggable-container-verticalStacks the sortable items vertically.
.vd-draggable-itemA reorderable child inside a container.
.vd-drop-zoneA target area. Shows a placeholder while empty; highlights on drag-over.
.is-disabledPrevents dragging the element.

Composable API (DraggableApi)

MethodDescription
useDraggable(root)Scans root for .vd-draggable / [data-draggable] items, .vd-draggable-container, and .vd-drop-zone elements, and returns a DraggableApi controller.
makeDraggable(target, options?)DraggableApi method — promotes an element or selector to .vd-draggable (optional { data } sets data-draggable) and wires drag/touch/keyboard listeners.
removeDraggable(target)DraggableApi method — tears down listeners and removes .vd-draggable / draggable / data-draggable from the target.
refresh()DraggableApi method — re-scans root to wire newly added draggable items, sortable containers, and drop zones.

Events

EventDescription
draggable:startFired on the element when a drag begins ({ element, data, position }).
draggable:dragFired continuously while dragging ({ element, data, position, delta }).
draggable:endFired when the drag ends ({ element, data, position, delta }).
draggable:dropFired on the .vd-drop-zone when an item is dropped ({ zone, element, data, position }).
draggable:reorderFired on the item when reordered via keyboard arrow keys ({ element, direction: 'up' | 'down' }).
Accessibility
  • Containers receive a aria-label and items are keyboard-reorderable — focus an item and use the arrow keys.
  • Handles keep the rest of the item text selectable for users who don't drag.
  • .is-disabled items are skipped by both pointer and keyboard interaction.
  • Uses native HTML5 Drag and Drop (draggable="true", dragstart/dragover/drop) paired with a touch fallback (touchmove with a .vd-drag-feedback ghost) and keyboard arrow-key reordering.