vael-ui v0.5.7

Directives

v-draggable

Lets you reorder a container's children by dragging them: tabs, files or any plain array, without the full <Sortable> component. It runs the same engine as <Sortable> and Tree, so the motion and drag preview match. Rows are tracked by position, so there's no keyboard support and no screen reader announcements; use <Sortable> when you need those. It only reorders: to move one element freely and decide where it lands when you let go (a card, a toast, a dialog), use useDrag. While you drag, the grabbed element floats as a preview and the original hides in place, with no styling from you.

Install

import { vDraggable } from 'vael-ui'

Examples

Overview / Activity / Settings

Value

NameTypeDescription
T[]T[]The array itself, reordered in place on drop.
itemsT[]The array to reorder.
axis'x' | 'y'The axis items reorder along: 'y' for a column, 'x' for a row. Default 'y'. When the items wrap onto more lines (a card grid), they reorder in reading order and make room slot by slot, on either axis.
handlestringA CSS selector for the grab area inside each child. Default: the whole child.
touchDragDelaynumberHow long a touch must hold a child still before a drag starts, in ms. Set it only when a child is also tappable for something else. Mouse and pen are unaffected. Default 0.
disabledbooleanTurns off dragging.
onReorder(from: number, to: number) => voidFires on a committed drop with the old and new index. Items have no stable key here, so the index is the only way to identify the moved item.
group / groupIdSortableGroupHandle / string | numberShares drag sessions with other lists (v-draggable or useSortable()) that get the same handle from useSortableGroup(). Items can then move between them. Without a groupId, it assigns one.