Laravel Blade Sortable

Packages

February 10th, 2021

laravel-blade-sortable-featured.png

Laravel Blade Sortable provides custom blade components to add sortable, drag-and-drop HTML elements in your Laravel apps.

This package uses SortableJS and AlpineJS to enable sorting, and provides two custom blade components to enable sorting of DOM elements:

1<x-laravel-blade-sortable::sortable as="ul">
2 <x-laravel-blade-sortable::sortable-item sort-key="jason">
3 Jason
4 </x-laravel-blade-sortable::sortable-item>
5 <x-laravel-blade-sortable::sortable-item sort-key="andres">
6 Andres
7 </x-laravel-blade-sortable::sortable-item>
8 <x-laravel-blade-sortable::sortable-item sort-key="matt">
9 Matt
10 </x-laravel-blade-sortable::sortable-item>
11 <x-laravel-blade-sortable::sortable-item sort-key="james">
12 James
13 </x-laravel-blade-sortable::sortable-item>
14</x-laravel-blade-sortable::sortable>

Without writing any custom JavaScript, you can achieve something like the following:

Demo of Sortable Behavior

This package also has Laravel Livewire support along with other advanced customization options. Check out the readme, which details component options as well as advanced features available.

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.