Data Grid
Search, sort, select and edit products in a server-rendered collection.
Studio inventory
Product catalog
HTML
<div class="rl-grid-mount" hx-get="/demo/collections/grid?row=1&row=2" hx-trigger="load" hx-swap="innerHTML"><section class="rl-collection" data-rl-grid data-inventory-revision="0" hx-target="closest [data-rl-grid]" hx-swap="outerHTML" hx-sync="closest [data-rl-grid]:drop" hx-include="closest [data-rl-grid]" hx-params="q,filter,sort,row,returnFocus">
<input type="hidden" name="revision" value="0">
<div class="rl-collection-head"><div><h2>Studio inventory</h2><p>Product catalog</p></div><button type="button" class="rl-button rl-button-primary rl-button-sm" data-grid-add hx-get="/demo/collections/grid/new">Add product</button></div>
<form class="rl-collection-filters" role="search" hx-get="/demo/collections/grid" hx-vals='{"returnFocus":"search"}'>
<input class="rl-input" type="search" name="q" value="" maxlength="120" placeholder="Search products…" aria-label="Search products">
<select class="rl-select" name="filter" aria-label="Filter by status"><option value="">All statuses</option><option value="Active">Active</option><option value="Draft">Draft</option><option value="Archived">Archived</option></select>
<select class="rl-select" name="sort" aria-label="Sort products"><option value="name" selected>Name A–Z</option><option value="name-desc">Name Z–A</option><option value="status">Status</option></select>
<button type="submit" class="rl-button rl-button-outline rl-button-sm">Apply</button>
</form>
<p class="rl-collection-message" role="status" data-grid-message></p>
<p class="rl-collection-error" role="alert" data-grid-error hidden></p>
<form class="rl-collection-body" hx-post="/demo/collections/grid/bulk" hx-params="revision,q,filter,sort,row,next">
<div class="rl-collection-scroll"><table class="rl-table rl-collection-table"><caption class="rl-collection-sr">Studio products</caption><thead><tr><th scope="col"><label class="rl-collection-pick"><input type="checkbox" class="rl-checkbox" data-grid-all aria-label="Select all visible products"></label></th><th scope="col">Product</th><th scope="col">Status</th><th scope="col"><span class="rl-collection-sr">Actions</span></th></tr></thead>
<tbody><tr><td><label class="rl-collection-pick"><input class="rl-checkbox" type="checkbox" name="row" value="1" aria-label="Select Arc Lounge Chair" checked></label></td><th scope="row"><strong>Arc Lounge Chair</strong><small>RL-1042 · Furniture</small><span class="rl-small-status"><span class="rl-collection-status" data-status="Active">Active</span></span></th><td><span class="rl-collection-status" data-status="Active">Active</span></td><td><div class="rl-collection-row-actions"><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-edit="1" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/1/edit" aria-label="Edit Arc Lounge Chair">Edit</button><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-delete="1" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/1/confirm" aria-label="Delete Arc Lounge Chair">Delete</button></div></td></tr><tr><td><label class="rl-collection-pick"><input class="rl-checkbox" type="checkbox" name="row" value="6" aria-label="Select Arc Task Lamp"></label></td><th scope="row"><strong>Arc Task Lamp</strong><small>SL-204 · Lighting</small><span class="rl-small-status"><span class="rl-collection-status" data-status="Active">Active</span></span></th><td><span class="rl-collection-status" data-status="Active">Active</span></td><td><div class="rl-collection-row-actions"><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-edit="6" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/6/edit" aria-label="Edit Arc Task Lamp">Edit</button><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-delete="6" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/6/confirm" aria-label="Delete Arc Task Lamp">Delete</button></div></td></tr><tr><td><label class="rl-collection-pick"><input class="rl-checkbox" type="checkbox" name="row" value="5" aria-label="Select Dune Throw"></label></td><th scope="row"><strong>Dune Throw</strong><small>RL-1151 · Textiles</small><span class="rl-small-status"><span class="rl-collection-status" data-status="Archived">Archived</span></span></th><td><span class="rl-collection-status" data-status="Archived">Archived</span></td><td><div class="rl-collection-row-actions"><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-edit="5" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/5/edit" aria-label="Edit Dune Throw">Edit</button><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-delete="5" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/5/confirm" aria-label="Delete Dune Throw">Delete</button></div></td></tr><tr><td><label class="rl-collection-pick"><input class="rl-checkbox" type="checkbox" name="row" value="3" aria-label="Select Fold Side Table"></label></td><th scope="row"><strong>Fold Side Table</strong><small>RL-1116 · Furniture</small><span class="rl-small-status"><span class="rl-collection-status" data-status="Active">Active</span></span></th><td><span class="rl-collection-status" data-status="Active">Active</span></td><td><div class="rl-collection-row-actions"><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-edit="3" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/3/edit" aria-label="Edit Fold Side Table">Edit</button><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-delete="3" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/3/confirm" aria-label="Delete Fold Side Table">Delete</button></div></td></tr><tr><td><label class="rl-collection-pick"><input class="rl-checkbox" type="checkbox" name="row" value="4" aria-label="Select Forma Vase"></label></td><th scope="row"><strong>Forma Vase</strong><small>RL-1140 · Objects</small><span class="rl-small-status"><span class="rl-collection-status" data-status="Active">Active</span></span></th><td><span class="rl-collection-status" data-status="Active">Active</span></td><td><div class="rl-collection-row-actions"><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-edit="4" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/4/edit" aria-label="Edit Forma Vase">Edit</button><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-delete="4" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/4/confirm" aria-label="Delete Forma Vase">Delete</button></div></td></tr><tr><td><label class="rl-collection-pick"><input class="rl-checkbox" type="checkbox" name="row" value="2" aria-label="Select Halo Pendant" checked></label></td><th scope="row"><strong>Halo Pendant</strong><small>RL-1078 · Lighting</small><span class="rl-small-status"><span class="rl-collection-status" data-status="Draft">Draft</span></span></th><td><span class="rl-collection-status" data-status="Draft">Draft</span></td><td><div class="rl-collection-row-actions"><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-edit="2" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/2/edit" aria-label="Edit Halo Pendant">Edit</button><button type="button" class="rl-button rl-button-ghost rl-button-sm" data-grid-delete="2" hx-params="q,filter,sort,row,returnFocus" hx-get="/demo/collections/grid/2/confirm" aria-label="Delete Halo Pendant">Delete</button></div></td></tr></tbody></table></div>
<div class="rl-action-bar" data-grid-bar hidden><output data-grid-count></output><select class="rl-select" name="next" aria-label="Set selected products to"><option value="Active">Active</option><option value="Draft">Draft</option><option value="Archived" selected>Archived</option></select><button class="rl-button rl-button-primary rl-button-sm" type="submit">Update selected</button><button class="rl-button rl-button-ghost rl-button-sm" data-grid-clear type="button">Clear</button></div>
</form><footer class="rl-collection-foot">6 of 6 products</footer>
</section></div>HTTP exchange
Use the preview to see the request and the HTML your server returns.Use GET to return a filtered grid. Save, delete and bulk actions POST to the host and return the same section. Validation returns 422 with the draft. Selection applies to visible rows. Supply the displayed revision to handle changes in another workspace.
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 ↓