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?q=No+such+SKU" 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="No such SKU" 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" disabled></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 colspan="4"><div class="rl-empty-state"><span class="rl-empty-glyph" aria-hidden="true"></span><strong>No matching products</strong><p>Change the search or status filter.</p></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">0 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 ↓