Component

Drag & Drop

<wr-sortable-list> wraps CDK's cdkDropList + cdkDrag with a signal-based two-way [(items)] binding. Includes the [wrDragHandle] helper and themed .cdk-drag-preview / .cdk-drag-placeholder defaults. Touch-ready: a default touch start-delay lets a quick swipe scroll the list while a hold begins a drag.

Import

import { WrSortableList, WrDragHandle, type WrSortableReorderEvent } from 'ngwr/drag-drop';

Basic — drag the row

<wr-sortable-list [(items)]="rows" (reorder)="onReorder($event)">
  <ng-template let-row let-i="index">
    <div class="row">{{ i + 1 }}. {{ row.label }}</div>
  </ng-template>
</wr-sortable-list>
#1Design the empty state
#2Wire the new sidebar config
#3Run lighthouse on the homepage
#4Write release notes
#5Bump the version

Press Space to pick this item up, then use the arrow keys to move it. Press Space again to drop it, or Escape to put it back.

Last reorder: —

With drag handle

<wr-sortable-list [(items)]="rows">
  <ng-template let-row>
    <div class="row">
      <span wrDragHandle class="grip">≡</span>
      <span>{{ row.label }}</span>
    </div>
  </ng-template>
</wr-sortable-list>
Design the empty state
Wire the new sidebar config
Run lighthouse on the homepage
Write release notes
Bump the version

Press Space to pick this item up, then use the arrow keys to move it. Press Space again to drop it, or Escape to put it back.

Only the ≡ handle starts a drag — clicking the row text does nothing.

API

NameDescriptionTypeDefault
itemsrequiredTwo-way bound items array. Emits the reordered array after drop.T[]
orientationLayout direction. Drives CDK's cdkDropListOrientation.'vertical' | 'horizontal''vertical'
disabledDisable dragging.booleanfalse
lockAxisRestrict drag movement to one axis.'x' | 'y'
dragStartDelayDelay (ms) before a drag begins. The touch delay lets a quick swipe scroll the list while a brief hold starts the drag; mouse stays instant.number | { touch: number; mouse: number }{ touch: 150, mouse: 0 }
trackBytrackBy for the inner @for.(index: number, item: T) => unknownidentity
(reorder)Fires after a successful reorder with the new array + indices.WrSortableReorderEvent<T>
[wrDragHandle]Restrict drag start to a handle element. Composes CDK's cdkDragHandle.directive