--- includeMockServer: true title: "Bulk Actions" description: Perform actions on multiple records icon: "icon-[mdi--checkbox-multiple-marked]" ---
## How it works Wrap a table in a `
`. Each row has a checkbox, and an action bar appears when any are checked. Clicking a row toggles its checkbox. ```html ...
Name Email Status
Joe Smith joe@smith.org Active
``` - [`hx-target`](/reference/attributes/hx-target)=`"this"` and [`hx-swap`](/reference/attributes/hx-swap)=`"outerHTML"` on the form mean every action replaces the entire form with the server's response. - Each action button uses [`hx-post`](/reference/attributes/hx-post) to a different endpoint. Only checked `name="selected"` values are submitted. - Use [`hx-target:inherited`](/docs#attribute-inheritance) to avoid repeating target declarations on each action button. ### Clickable rows Make the whole row a click target so users don't have to aim for the small checkbox: ```html ... ``` The `if event.target.tagName !== 'INPUT'` guard prevents double-toggling when clicking directly on the checkbox. Highlighting the selected row is pure CSS: ```css tr:has(input:checked) { background: var(--selected-bg); } ``` ### Conditional action bar Show the action bar only when at least one checkbox is checked. With CSS `:has()`: ```css .action-bar { display: none; } form:has(input[name="selected"]:checked) .action-bar { display: flex; } ``` Or with hyperscript on the `` (for browsers without `:has()` support): ```html ``` ### Select all A checkbox in the header toggles all row checkboxes: ```html ``` ### Server response The server processes the selected emails, performs the bulk action, and re-renders the full table. Selections are cleared and statuses reflect the update: ```html
Activated 1 user
```