Bulk action bar

Select rows to show the bar

Put the bar after a table and point it at the table with data-table. It stays out of sight until a row is selected, then shows the count and the actions. Clear unselects every row.

Order Customer Total
#110963Emma Wilson$79.00
#110962Olivia Brown$26.00
#110961James Carter$364.50
#110960Noah Davis$12.00

0 selected

Rows that start selected

A server-rendered selection shows the bar on load. The actions are ordinary buttons: read the rows with tsunami.table.selected(table) in the click handler.

Order Customer Total
#110963Emma Wilson$79.00
#110962Olivia Brown$26.00
#110961James Carter$364.50
#110960Noah Davis$12.00

0 selected

Nothing exported yet.

Behavior

The bar is sticky at the bottom of its container. While nothing is selected it is invisible but keeps its space, so the page does not move when it appears. The count sits in [data-bulk-count]; put aria-live="polite" on its paragraph so screen readers hear the change. Without data-table, the bar uses the first .table in its parent. Selection comes from the checkboxes of the Data table, so select-all, filters and pages work as they do there.

API

js/bulk-bar.js also works with bars added later. There is no event of its own: listen for tsunami:select on the table.

FunctionDescription
tsunami.bulkBar.update(bar)Counts the selected rows again. Call it after a script changes the rows without a change event.
tsunami.bulkBar.clear(bar)Unselects every row of the bar's table. Same as the Clear button.
EventOnDetail
tsunami:selecttable (bubbles){ rows, count }. Fired by the Data table; the bar updates from it.

Attributes

Attribute / elementValuesDescription
.bulk-barSticky bar with a top border
data-tabletable idThe table whose selection the bar shows. Default: the first .table in the parent.
data-activetrue, falseSet by the script: whether any row is selected.
[data-bulk-count]Receives the number of selected rows.
[data-bulk-clear]A button that unselects every row.
.bulk-bar > pThe count text, muted
.bulk-bar > divGroup of action buttons