| Name | Role | Items |
|---|---|---|
| Alice | Designer | 14 |
| Bob | Engineer | 7 |
| Carla | PM | 22 |
| Name | Role | Qty | |
|---|---|---|---|
| Alice | Designer | 14 | |
| Bob | Engineer | 7 | |
| Carla | PM | 22 | |
| Dan | Engineer | 3 |
When a child element with data-brut-role="empty-state" is present, BRUT toggles it automatically based on tbody contents. Click the button to clear the rows and see the swap.
| SKU | Title | Stock |
|---|---|---|
| B-001 | Raw concrete mug | 9 |
| B-002 | Bone-white tee | 44 |
No items yetYour inventory list is empty. Add an item to get started. | ||
| SKU | Title | Stock |
|---|---|---|
| A-001 | Bone-white tee | 122 |
| A-002 | Hard-shadow cap | 38 |
// Re-fetch sorted rows from a server endpoint when a header is clicked.
document.querySelector('[data-brut="table"]').addEventListener('brut:sort', function (e) {
var key = e.detail.key;
var direction = e.detail.direction; // "ascending" | "descending" | "none"
// e.detail.value === { key, direction } — canonical state object.
fetch('/api/rows?sort=' + encodeURIComponent(key) + '&dir=' + encodeURIComponent(direction))
.then(function (r) { return r.json(); })
.then(function (rows) { /* re-render tbody from rows */ });
});