Logo Logo v2.0
Image Description Image Description

No Results

  • Get Support
  • Preview Demo
Logo Logo v2.0
  • Documentation
  • Introduction
  • Getting started
  • Getting Started
  • Gulp
  • Dark Mode New
  • Customization
  • Credits
  • Changelog
  • Design & Graphics
  • Bootstrap Icons
  • Illustrations
  • Components
  • Accordion
  • Alerts
  • Avatars
  • Badge
  • Breadcrumb
  • Buttons
  • Button Group
  • Cards
  • Collapse
  • Column Divider
  • Devices
  • Divider
  • Dropdowns
  • Icons
  • List Group
  • Lists
  • Legend Indicator
  • Modal
  • Offcanvas
  • Page Header
  • Pagination
  • Popovers
  • Progress
  • Profile
  • Shapes
  • Sliding Image
  • Spinners
  • Steps
  • Tab
  • Toasts
  • Tooltips
  • Typography
  • Navbars
  • Navbar
  • Navs
  • Mega Menu
  • Navbar Vertical Aside
  • Scrollspy
  • Tables
  • Tables
  • Datatables
  • Sticky Header
  • Basic forms
  • Basic Forms
  • Checks & Switches
  • Input Group
  • Advanced Forms
  • Advanced Select
  • Datepicker (Flatpickr)
  • Date Range Picker
  • Calendar (Fullcalendar)
  • File Attachments
  • Drag’ n’ Drop File Uploads
  • WYSIWYG Editor
  • Quantity Counter
  • Copy to Clipboard
  • Input Mask
  • Step Forms (Wizards)
  • Add Field
  • Toggle Password
  • Count Characters
  • Form Search
  • Toggle Switch
  • Google reCAPTCHA
  • Charts
  • Chart.js
  • Counter
  • Circles.js (Pie Chart)
  • Others
  • Fullscreen Lightbox
  • Leaflet
  • JSVectorMap
  • SortableJS
  • Sticky Block
  • Go To
  • Utilities
  • Backgrounds
  • Borders
  • Colors
  • Links
  • Position
  • Shadows
  • Sizing
  • Spacing
  • Z-index
  • Opacity

SortableJS

SortableJS JavaScript library for reorderable drag-and-drop lists.

SortableJS documentation

How to use

Copy-paste the following <script> near the end of your pages under JS Implementing Plugins to enable it.

        
          <script src="../assets/vendor/sortablejs/Sortable.min.js"></script>
        
      

Copy-paste the following <script> near the end of your pages under JS Front to enable it.

        
        
      

Copy-paste the init function under JS Plugins Init., before the closing </body> tag, to enable it.

        
          <script>
            (function() {
              // INITIALIZATION OF SORTABLE
              // =======================================================
              HSCore.components.HSSortable.init('.js-sortable')
            });
          </script>
        
      

Simple list example

  • Preview
  • HTML
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
              
                <!-- List Group -->
                <div class="js-sortable sortablejs-custom list-group"
                    data-hs-sortable-options='{
                      "animation": 150,
                      "group": "listGroup"
                    }'>
                 <div class="list-group-item">Item 1</div>
                 <div class="list-group-item">Item 2</div>
                 <div class="list-group-item">Item 3</div>
                 <div class="list-group-item">Item 4</div>
                 <div class="list-group-item">Item 5</div>
                 <div class="list-group-item">Item 6</div>
               </div>
                <!-- End List Group -->
              
            

Shared lists

Use "group": "listGroupName"

  • Preview
  • HTML
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
              
                <div class="row">
                  <div class="col-md-6">
                    <!-- List Group -->
                    <div class="js-sortable sortablejs-custom list-group"
                         data-hs-sortable-options='{
                           "animation": 150,
                           "group": "listGroup"
                         }'>
                      <div class="list-group-item">Item 1</div>
                      <div class="list-group-item">Item 2</div>
                      <div class="list-group-item">Item 3</div>
                      <div class="list-group-item">Item 4</div>
                      <div class="list-group-item">Item 5</div>
                      <div class="list-group-item">Item 6</div>
                    </div>
                    <!-- End List Group -->
                  </div>

                  <div class="col-md-6">
                    <!-- List Group -->
                    <div class="js-sortable sortablejs-custom list-group"
                         data-hs-sortable-options='{
                           "animation": 150,
                           "group": "listGroup"
                         }'>
                      <div class="list-group-item bg-light">Item 1</div>
                      <div class="list-group-item bg-light">Item 2</div>
                      <div class="list-group-item bg-light">Item 3</div>
                      <div class="list-group-item bg-light">Item 4</div>
                      <div class="list-group-item bg-light">Item 5</div>
                      <div class="list-group-item bg-light">Item 6</div>
                    </div>
                    <!-- End List Group -->
                  </div>
                </div>
                <!-- End Row -->
              
            

Disable sorting

Try sorting the list on the left. It is not possible because it has it's sort option set to false. However, you can still drag from the list on the left to the list on the right.

  • Preview
  • HTML
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
              
                <div class="row">
                  <div class="col-md-6">
                    <!-- List Group -->
                    <div class="js-sortable sortablejs-custom list-group"
                         data-hs-sortable-options='{
                           "animation": 150,
                           "group": {
                             "name": "listGroup3",
                             "pull": "clone",
                             "put": false
                           }
                         }'>
                      <div class="list-group-item">Item 1</div>
                      <div class="list-group-item">Item 2</div>
                      <div class="list-group-item">Item 3</div>
                      <div class="list-group-item">Item 4</div>
                      <div class="list-group-item">Item 5</div>
                      <div class="list-group-item">Item 6</div>
                    </div>
                    <!-- End List Group -->
                  </div>

                  <div class="col-md-6">
                    <!-- List Group -->
                    <div class="js-sortable sortablejs-custom list-group"
                         data-hs-sortable-options='{
                           "animation": 150,
                           "group": "listGroup3"
                         }'>
                      <div class="list-group-item bg-light">Item 1</div>
                      <div class="list-group-item bg-light">Item 2</div>
                      <div class="list-group-item bg-light">Item 3</div>
                      <div class="list-group-item bg-light">Item 4</div>
                      <div class="list-group-item bg-light">Item 5</div>
                      <div class="list-group-item bg-light">Item 6</div>
                    </div>
                    <!-- End List Group -->
                  </div>
                </div>
                <!-- End Row -->
              
            

Handle

  • Preview
  • HTML
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
              
                <!-- List Group -->
                <div class="js-sortable sortablejs-custom list-group"
                    data-hs-sortable-options='{
                      "animation": 150,
                      "handle": ".sortablejs-custom-handle"
                    }'>
                  <div class="list-group-item">
                    <i class="sortablejs-custom-handle bi-grip-horizontal list-group-icon"></i> Item 1
                  </div>
                  <div class="list-group-item">
                    <i class="sortablejs-custom-handle bi-grip-horizontal list-group-icon"></i> Item 2
                  </div>
                  <div class="list-group-item">
                    <i class="sortablejs-custom-handle bi-grip-horizontal list-group-icon"></i> Item 3
                  </div>
                  <div class="list-group-item">
                    <i class="sortablejs-custom-handle bi-grip-horizontal list-group-icon"></i> Item 4
                  </div>
                  <div class="list-group-item">
                    <i class="sortablejs-custom-handle bi-grip-horizontal list-group-icon"></i> Item 5
                  </div>
                  <div class="list-group-item">
                    <i class="sortablejs-custom-handle bi-grip-horizontal list-group-icon"></i> Item 6
                  </div>
                </div>
                <!-- End List Group -->
              
            

Filter

Try dragging the item with a red background. It cannot be done, because that item is filtered out using the filter option.

  • Preview
  • HTML
Item 1
Filtered
Item 3
Item 4
Item 5
Item 6
              
                <!-- List Group -->
                <div class="js-sortable list-group"
                     data-hs-sortable-options='{
                        "animation": 150,
                        "filter": ".sortablejs-custom-disabled"
                      }'>
                  <div class="list-group-item">Item 1</div>
                  <div class="list-group-item sortablejs-custom-disabled bg-danger text-white">Filtered</div>
                  <div class="list-group-item">Item 3</div>
                  <div class="list-group-item">Item 4</div>
                  <div class="list-group-item">Item 5</div>
                  <div class="list-group-item">Item 6</div>
                </div>
                <!-- End List Group -->
              
            

Grid

  • Preview
  • HTML
1
2
3
4
5
6
7
8
9
10
11
12
              
                <!-- List Group -->
                <div class="js-sortable row"
                     data-hs-sortable-options='{
                       "animation": 150,
                       "ghostClass": "sortablejs-custom-chosen-child"
                     }'>
                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">1</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">2</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">3</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">4</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">5</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">6</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">7</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">8</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">9</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">10</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">11</div>
                    </div>
                  </div>

                  <div class="col-md-2 mb-3">
                    <div class="card">
                      <div class="card-body text-center">12</div>
                    </div>
                  </div>
                </div>
                <!-- End List Group -->
              
            

Nested

  • Preview
  • HTML
Item 1
Item 2

Item 3

Item 3.1
Item 3.2
Item 3.3
Item 3.4
Item 4
Item 5
Item 6
              
                <!-- List Group -->
                <div class="js-sortable list-group"
                    data-hs-sortable-options='{
                      "animation": 150,
                      "group": "listGroup4",
                      "fallbackOnBody": true
                    }'>
                  <div class="list-group-item">Item 1</div>
                  <div class="list-group-item">Item 2</div>
                  <div class="list-group-item">
                    <h4 class="h5">Item 3</h4>

                    <div class="js-sortable list-group"
                         data-hs-sortable-options='{
                           "animation": 150,
                           "group": "listGroup5"
                         }'>
                      <div class="list-group-item">Item 3.1</div>
                      <div class="list-group-item">Item 3.2</div>
                      <div class="list-group-item">Item 3.3</div>
                      <div class="list-group-item">Item 3.4</div>
                    </div>
                  </div>
                  <div class="list-group-item">Item 4</div>
                  <div class="list-group-item">Item 5</div>
                  <div class="list-group-item">Item 6</div>
                </div>
                <!-- End List Group -->
              
            

Multiple Drag

The MultiDrag option allows for multiple items to be dragged at a time. You can click to "select" multiple items, and then drag them as one item.

Use "multiDrag": true

  • Preview
  • HTML
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
              
                <!-- List Group -->
                <div class="js-sortable list-group"
                     data-hs-sortable-options='{
                       "animation": 150,
                       "multiDrag": true,
                       "selectedClass": "active"
                     }'>
                  <div class="list-group-item">Item 1</div>
                  <div class="list-group-item">Item 2</div>
                  <div class="list-group-item">Item 3</div>
                  <div class="list-group-item">Item 4</div>
                  <div class="list-group-item">Item 5</div>
                  <div class="list-group-item">Item 6</div>
                </div>
                <!-- End List Group -->
              
            

Swap

The Swap option changes the behaviour of Sortable to allow for items to be swapped with eachother rather than sorted.

Use "swap": true

  • Preview
  • HTML
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
              
                <!-- List Group -->
                <div class="js-sortable list-group"
                     data-hs-sortable-options='{
                       "animation": 150,
                       "swap": true,
                       "swapClass": "active"
                     }'>
                  <div class="list-group-item">Item 1</div>
                  <div class="list-group-item">Item 2</div>
                  <div class="list-group-item">Item 3</div>
                  <div class="list-group-item">Item 4</div>
                  <div class="list-group-item">Item 5</div>
                  <div class="list-group-item">Item 6</div>
                </div>
                <!-- End List Group -->
              
            

Links

  • Preview
  • HTML
Sortable with link 1 Sortable with link 2 Sortable with link 3 Sortable with link 4 Sortable with link 5 Sortable with link 6
              
                <!-- List Group -->
                <div class="js-sortable list-group">
                  <a class="js-sortable list-group-item sortablejs-custom-handle" href="#">Sortable with link 1</a>
                  <a class="js-sortable list-group-item sortablejs-custom-handle" href="#">Sortable with link 2</a>
                  <a class="js-sortable list-group-item sortablejs-custom-handle" href="#">Sortable with link 3</a>
                  <a class="js-sortable list-group-item sortablejs-custom-handle" href="#">Sortable with link 4</a>
                  <a class="js-sortable list-group-item sortablejs-custom-handle" href="#">Sortable with link 5</a>
                  <a class="js-sortable list-group-item sortablejs-custom-handle" href="#">Sortable with link 6</a>
                </div>
                <!-- End List Group -->
              
            

Data-href with modal example

  • Preview
  • HTML
Sortable with modal link 1 Sortable with modal link 2 Sortable with modal link 3 Sortable with modal link 4 Sortable with modal link 5 Sortable with modal link 6
Modal title
...
              
                <!-- List Group -->
                <div class="js-sortable list-group">
                  <a class="js-sortable-modal-link list-group-item sortablejs-custom-handle" data-bs-toggle="modal" data-bs-target="#exampleModal" href="javascript:;">Sortable with modal link 1</a>
                  <a class="js-sortable-modal-link list-group-item sortablejs-custom-handle" data-bs-toggle="modal" data-bs-target="#exampleModal" href="javascript:;">Sortable with modal link 2</a>
                  <a class="js-sortable-modal-link list-group-item sortablejs-custom-handle" data-bs-toggle="modal" data-bs-target="#exampleModal" href="javascript:;">Sortable with modal link 3</a>
                  <a class="js-sortable-modal-link list-group-item sortablejs-custom-handle" data-bs-toggle="modal" data-bs-target="#exampleModal" href="javascript:;">Sortable with modal link 4</a>
                  <a class="js-sortable-modal-link list-group-item sortablejs-custom-handle" data-bs-toggle="modal" data-bs-target="#exampleModal" href="javascript:;">Sortable with modal link 5</a>
                  <a class="js-sortable-modal-link list-group-item sortablejs-custom-handle" data-bs-toggle="modal" data-bs-target="#exampleModal" href="javascript:;">Sortable with modal link 6</a>
                </div>
                <!-- End List Group -->

                <!-- Modal -->
                <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                  <div class="modal-dialog">
                    <div class="modal-content">
                      <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                      </div>
                      <div class="modal-body">
                        ...
                      </div>
                      <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary">Save changes</button>
                      </div>
                    </div>
                  </div>
                </div>
                <!-- End Modal -->
              
            

Methods

Parameters Description Default value

ghostClass

Class when draging. sortable-chosen-main