AdaptTable for Unstyled

Row reordering in Unstyled

Compose rowReorder from @adapttable/angular-unstyled/row-reorder and a grip appears on every row. Drag it, or press Space to lift a row, the arrows to move it and Space to drop it; a live region announces each step.

The table never mutates your array: onRowReorder asks the host with the row's old and new positions and the row itself, and the host writes. This page applies each move with core's applyRowReorder and says what it did.

The code

import { Component, input, signal } from "@angular/core";
import { applyRowReorder } from "@adapttable/core";
import type { ColumnDef } from "@adapttable/angular";
import { AdaptDataTable } from "@adapttable/angular-unstyled";
import { rowReorder } from "@adapttable/angular-unstyled/row-reorder";

const columns: ColumnDef<Person>[] = [
  { key: "name", sortable: true },
  { key: "team" },
  { key: "budget", sortable: true },
];

@Component({
  selector: "app-people",
  imports: [AdaptDataTable],
  template: `
    <adapt-data-table
      [data]="order() ?? rows()"
      [columns]="columns"
      [rowKey]="rowKey"
      [features]="features"
    />
  `,
})
export class People {
  readonly rows = input.required<readonly Person[]>();
  readonly columns = columns;
  readonly rowKey = (row: Person) => row.id;
  readonly order = signal<readonly Person[] | null>(null);
  readonly features = [
    rowReorder<Person>((from, to) =>
      this.order.set(applyRowReorder(this.order() ?? this.rows(), from, to))
    ),
  ];
}

Install

pnpm add @adapttable/angular-unstyled @adapttable/angular @adapttable/core

The same feature in the other kits

More Unstyled features

Reference: row-reordering. More of this kit: AdaptTable for Unstyled, or the live demo.