Skip to content

Reorder Rows

Change the order of table or list rows from the keyboard and save it with a form.

View template
Content languages
LanguageCodeActions
English en
German de
French fr
Dutch nl

Put data-mero-reorder on the tbody or List View and data-mero-reorder-id on each row. Choose Move up or Move down in a row’s Actions menu, or press Alt+Up Arrow or Alt+Down Arrow with focus anywhere in the row. Focus stays on the moved row and the data-mero-reorder-status region announces the new position, such as “French moved to position 2 of 4”. Mero marks Move up in the first row and Move down in the last as aria-disabled. Each row carries a hidden input with its ID, so submitting the form posts the rows in their new order. The bubbling mero:reorder event carries the new order in event.detail.order; set hx-trigger to mero:reorder and hx-sync to this:queue last on the form to save every move, so moves made while a save is in flight end with one request carrying the latest order. Pointer drag is not included.

Use in your app

Copy these tags into your page head once. Serve the files at the paths shown, then add the example’s template to your page.

Page assets
<link rel="stylesheet" href="/mero.css">
<link rel="stylesheet" href="/mero-collections.css">
<script defer src="/vendor/htmx.min.js"></script>
<script defer src="/mero.js"></script>
<script defer src="/mero-collections.js"></script>

Point the HTMX attributes at your own HTML endpoints. Use the live preview’s HTTP exchange to inspect the request and response.

Download library and examples ↓