SO

Sortablejs

sortablejs

JavaScript library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery required. Supports Meteor, AngularJS, React, Polymer, Vue, Knockout and any CSS library, e.g. Bootstrap.

Tables
sortable
reorder
drag
meteor
angular
ng-sortable
react
vue
mixin
sortablejs
Stars
31k
Weekly
2.8M
Open issues
526
Bundle
~25 kB

Installation

npm install sortablejs

Code example

import { useSortablejs } from "sortablejs";

const rows = [
  { id: 1, name: "Ada", role: "Engineer" },
  { id: 2, name: "Linus", role: "Maintainer" },
];

export function Example() {
  const table = useSortablejs({ data: rows, columns: [{ accessorKey: "name" }, { accessorKey: "role" }] });
  return <pre>{JSON.stringify(table, null, 2)}</pre>;
}

Pros & cons

Pros

  • Actively maintained by rubaxa
  • 2.8M weekly downloads. Battle tested
  • MIT licensed

Considerations

  • Adds roughly ~25 kB to your bundle
  • Needs client-only rendering in SSR frameworks
  • Not supported in React Native
  • 526 open issues on GitHub

FAQs

Alternatives & similar libraries