PHPackages                             bigenergy/laravel-blade-sortable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. bigenergy/laravel-blade-sortable

ActiveLibrary[Templating &amp; Views](/categories/templating)

bigenergy/laravel-blade-sortable
================================

Custom Blade components to add sortable/drag-and-drop HTML elements in your apps (support laravel 9+)

1.3.3(3y ago)61.1k1MITPHPPHP ^8.0

Since Dec 23Pushed 3y agoCompare

[ Source](https://github.com/bigenergy/laravel-blade-sortable-updated)[ Packagist](https://packagist.org/packages/bigenergy/laravel-blade-sortable)[ Docs](https://github.com/asantibanez/laravel-blade-sortable)[ RSS](/packages/bigenergy-laravel-blade-sortable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Laravel Blade Sortable Updated
==============================

[](#laravel-blade-sortable-updated)

Fork for support new laravel versions

[![Latest Version on Packagist](https://camo.githubusercontent.com/8416678c57a54342bce97d2d7aa77fee4fe2d18ec3fe9e56b4d4c969ba35ea63/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626967656e657267792f6c61726176656c2d626c6164652d736f727461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bigenergy/laravel-blade-sortable)[![Total Downloads](https://camo.githubusercontent.com/7cd950981709c7387f926af5f4ef0dfd5aec2f029aaa86023249dbd1b0c88a08/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626967656e657267792f6c61726176656c2d626c6164652d736f727461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bigenergy/laravel-blade-sortable)

[![Laravel Blade Sortable](https://camo.githubusercontent.com/8a34ce1056c0492dad264ad66ed83605c0cece8a87ea2eacf5203e3ff9719673/68747470733a2f2f6c61726176656c2d6f672e6265796f6e64636f2e64652f4c61726176656c253230426c616465253230536f727461626c652e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d626967656e657267792532466c61726176656c2d626c6164652d736f727461626c65267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d437573746f6d2b426c6164652b636f6d706f6e656e74732b746f2b6164642b736f727461626c65253246647261672d616e642d64726f702b48544d4c2b656c656d656e74732b696e2b796f75722b61707073266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d6d656e75)](https://camo.githubusercontent.com/8a34ce1056c0492dad264ad66ed83605c0cece8a87ea2eacf5203e3ff9719673/68747470733a2f2f6c61726176656c2d6f672e6265796f6e64636f2e64652f4c61726176656c253230426c616465253230536f727461626c652e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d626967656e657267792532466c61726176656c2d626c6164652d736f727461626c65267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d437573746f6d2b426c6164652b636f6d706f6e656e74732b746f2b6164642b736f727461626c65253246647261672d616e642d64726f702b48544d4c2b656c656d656e74732b696e2b796f75722b61707073266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d6d656e75)

Demo
----

[](#demo)

[Repo](https://github.com/asantibanez/laravel-blade-sortable-demo)

[![demo](https://github.com/bigenergy/laravel-blade-sortable/raw/master/demo.gif)](https://github.com/bigenergy/laravel-blade-sortable/raw/master/demo.gif)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require bigenergy/laravel-blade-sortable
```

After the package is installed, make sure to add `laravel-blade-sortable::scripts`components next to your other scripts.

```

```

Requirements
------------

[](#requirements)

Package requires `SortableJs` and `AlpineJs` to be installed in your application in order to enable sorting. Reach out to their respective documentation in order to set them up.

> NOTE: `SortableJs` must be available at the `window` object level in Javascript. To do this, import the library using
>
> `window.Sortable = require('sortablejs').default`
>
> or use any other similar approach

Usage
-----

[](#usage)

The package provides 2 custom Blade components to enable sorting of DOM elements:

- `laravel-blade-sortable::sortable`
- `laravel-blade-sortable::sortable-item`

### Sortable

[](#sortable)

`laravel-blade-sortable::sortable` is used as the wrapper element for your sortable/drag-and-drop items. It must be used to enclose the children it will enable sortable.

```

    {{-- Items here --}}

```

By default, the component renders a "div" as the wrapper node. You can customize this behavior by passing an `as` property to render the type of node you need.

```

    {{-- Items here --}}

```

> NOTE: Any other attribute you pass along (class, id, alt, etc) will be added to the element

If you would like to use custom Blade component as a wrapper node, you can also do this by passing a `component` property.

```

    {{-- Items here --}}

```

### Sortable Item

[](#sortable-item)

`laravel-blade-sortable::sortable-item` is used as the wrapper element for each item you want to enable sorting.

```

        Jason

        Andres

        Matt

        James

```

> NOTE: Similar to `laravel-blade-sortable::sortable`, you can pass a `as`or `component` property to render the type of node or custom component you desire.
>
> NOTE: Extra attributes like class, id, alt, etc can be passed along to and will be added to the item node.

As you may have noticed, every `laravel-blade-sortable::sortable-item`requires a `sort-key` property. This property will be used to keep track of the ordering of the elements. Should be unique too.

And that's it. You have now a sortable list rendered by Laravel Blade without any custom Javascript. 🔥

[![basic](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/basic.gif)](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/basic.gif)

That example looks awful though 😅. Because you can pass in any custom component or styling directly, you can customize the wrapper and item nodes according to your needs. Here's another example using TailwindCSS ❤️ and custom components

[![custom-component](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/custom-component.gif)](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/custom-component.gif)

Looks dope, right? 👌

Advanced Usage
--------------

[](#advanced-usage)

### As Form Input

[](#as-form-input)

The sort order of elements can be used alongside other input fields on form submissions. To enable this behavior, just pass a `name` prop to a `laravel-blade-sortable::sortable`component. The `name` should be the name of the input in your form.

```

        {{-- Items here --}}

```

By adding a `name` props, the component internally adds hidden inputs for each one of the items' `sort-key`.

[![as-form-input](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/as-form-input.gif)](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/as-form-input.gif)

Pretty neat! 👌

### With Livewire

[](#with-livewire)

Into Livewire? It's awesome. We know.

You can use this package within your Livewire views and use the sorting information in the component.

To get "sort change" updates in your Livewire component, just add the attribute `wire:onSortOrderChange` to a `x-laravel-blade-sortable::sortable`component. Adding this attribute will hook the Livewire component when a sorting event happens and will call the specified method/callback.

```

    {{-- Items here --}}

```

In the example above, every time your items are sorted, the `handleSortOrderChange`method will be called passing as argument an array with your items' `sort-key` in the current order.

[![livewire](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/livewire.gif)](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/livewire.gif)

Extra info is passed along too, so you can check extra data when processing the sort order

```
public function handleOnSortOrderChanged($sortOrder, $previousSortOrder, $name, $from, $to)
{
    // $sortOrder = new keys order
    // $previousSortOrder = keys previous order
    // $name = drop target name
    // $from = name of drop target from where the dragged/sorted item came from
    // $to = name of drop target to where the dragged/sorted item was placed
}
```

### Customization

[](#customization)

To support some advanced features of SortableJs, it is possible to pass the following props to a `laravel-blade-sortable::sortable` component:

- `animation`: milliseconds it takes to run the sorting animation. `150` is the default value.
- `ghost-class`: class added to the dragged object during sort. Default is `null`. Must be 1 class only.
- `drag-handle`: class name that will be used as the handle for dragging. Only the DOM element that has that class can enable sorting.

```

    {{-- Items here --}}

```

[![customization](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/customization.gif)](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/customization.gif)

### Multiple Drop Zones

[](#multiple-drop-zones)

Wanting to have different drop zones to drag/drop/sort elements? We have you covered. 😎

Just add a `group` string prop to a `laravel-blade-sortable::sortable` component. Add the same prop to another `laravel-blade-sortable::sortable` component on the same page and BOOM! Done!

```

    {{-- Items here --}}

    {{-- Items here --}}

```

[![drag-drop](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/drag-drop.gif)](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/drag-drop.gif)

### Enable/Disable sorting and/or drop

[](#enabledisable-sorting-andor-drop)

Use `:allow-sort=true|false` and `:allow-drop=true|false` to `x-laravel-blade-sortable::sortable` components to enable/disable sorting and/or drop of elements.

Both defaults to `true`.

```

    {{-- Items here --}}

```

[![disable-sort-drop](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/disable-sort-drop.gif)](https://github.com/asantibanez/laravel-blade-sortable/raw/master/examples/disable-sort-drop.gif)

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Andrés Santibáñez](https://github.com/asantibanez)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~41 days

Total

3

Last Release

1154d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1add0a583d67db3a3293c5896ba29ba127ff2288c2c45b9580bf036cef3e3812?d=identicon)[bigenergy](/maintainers/bigenergy)

---

Top Contributors

[![asantibanez](https://avatars.githubusercontent.com/u/5126648?v=4)](https://github.com/asantibanez "asantibanez (30 commits)")[![bigenergy](https://avatars.githubusercontent.com/u/17977139?v=4)](https://github.com/bigenergy "bigenergy (7 commits)")[![lukasleitsch](https://avatars.githubusercontent.com/u/3009245?v=4)](https://github.com/lukasleitsch "lukasleitsch (1 commits)")

---

Tags

asantibanezlaravel-blade-sortablebigenergylaravel-blade-sortable-updated

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bigenergy-laravel-blade-sortable/health.svg)

```
[![Health](https://phpackages.com/badges/bigenergy-laravel-blade-sortable/health.svg)](https://phpackages.com/packages/bigenergy-laravel-blade-sortable)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[asantibanez/laravel-blade-sortable

Custom Blade components to add sortable/drag-and-drop HTML elements in your apps

41152.2k](/packages/asantibanez-laravel-blade-sortable)[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k454.7k15](/packages/robsontenorio-mary)[livewire/blaze

A tool for optimizing Blade component performance by folding them into parent templates

688221.3k17](/packages/livewire-blaze)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
