Sortable Container
<sl-sortable-container> | SlSortableContainer
A container for sortable items.
Allow children of type sl-sortable-item
to be sorted in the vertical orientation only.
<sl-sortable-container> <sl-sortable-item>Item 1</sl-sortable-item> <sl-sortable-item>Item 2</sl-sortable-item> <sl-sortable-item>Item 3</sl-sortable-item> </sl-sortable-container>
Change event
Emits an sl-change
event when the order of the items changes.
<sl-sortable-container id="order-change-example"> <sl-sortable-item>Item 1</sl-sortable-item> <sl-sortable-item>Item 2</sl-sortable-item> <sl-sortable-item>Item 3</sl-sortable-item> </sl-sortable-container> <p id="order-change-result"></p> <script> const container = document.getElementById('order-change-example'); container.addEventListener('sl-change', (event) => { setTimeout(() => { document.getElementById('order-change-result').textContent = "New is order is: " + Array.from(container .querySelectorAll('sl-sortable-item')) .map(item => item.textContent) .join(', '); }, 100); }); </script>
Slots
Name | Description |
---|---|
(default) | The default slot. |
Learn more about using slots.
Events
Name | React Event | Description | Event Detail |
---|---|---|---|
sl-change |
|
When the sort order changes. | - |
Learn more about events.
Parts
Name | Description |
---|---|
base |
The component’s base wrapper. |
Learn more about customizing CSS parts.