# drag One pointer and keyboard model for sliders, resize handles, swipe to dismiss, drawers and sortable cards. A primary-button press on the element (or on its `handle`) arms the drag; it starts once the pointer has moved `threshold` px along `axis`, or after `delay` ms held within `tolerance` px, and the callbacks get the point, the distance from the start and the velocity. ```ts Signature function drag(el: HTMLElement, opts: DragOptions): Drag; type DragAxis = "x" | "y" | "both"; type DragSource = "pointer" | "keyboard"; ``` ## Options | Option | Type | Default | What it does | |---|---|---|---| | `handle` | `string \| HTMLElement` | the element | Where a press starts the drag: a selector inside the element, or an element. | | `axis` | `DragAxis` | `"both"` | Which movement counts. | | `threshold` | `number` | `3` | px moved before the drag starts. `0` starts on press, as a slider does. | | `delay` | `number` | `0` (off) | ms held before the drag starts, instead of the threshold. | | `tolerance` | `number` | `5` | With `delay`: px the pointer may move while held. | | `touch` | `{ threshold?, delay?, tolerance? }` | none | For touch presses only: replaces threshold, delay and tolerance, so a finger holds before it drags and a swipe still scrolls. | | `canStart` | `(e: PointerEvent \| KeyboardEvent) => boolean` | none | Called with the pointerdown or keydown that would start a drag; `false` ignores it. | | `keyboard` | `DragKeyboard \| false` | `{ mode: "step" }` | The keyboard model below; `false` turns keys off. | | `disabled` | `() => boolean` | none | Returns true while dragging must not start. | | `dir` | `"ltr" \| "rtl"` | the element's computed direction | Reading direction for step mode. | | `onStart` | `(s: DragState) => void \| boolean` | none | The drag is starting. Return `false` to refuse it. | | `onMove` | `(s: DragState) => void` | none | The pointer moved, or a grab-mode key moved the item. | | `onEnd` | `(s: DragState) => void` | none | The pointer was released, or the item dropped. | | `onCancel` | `(s: DragState) => void` | none | Escape, pointercancel, a lost capture, blur, a tab switch, a resize, or `cancel()`. | | `onStep` | `(step: DragStep) => void` | none | Step mode: one keyboard step. | | `label` | `() => string` | `aria-label`, else the text | Grab mode: the item's name in announcements. | | `announcements` | `DragAnnouncements \| false` | the defaults | Grab mode: `start`, `move`, `end` and `cancel` functions of `(label, state)` returning the message, merged over the defaults ("Picked up